//
//  Employees.m
//  A One POS
//
//  Created by AonePOS on 24/09/13.
//  Copyright (c) 2013 AonePOS. All rights reserved.
//

#import "Employees.h"
#import "Settings.h"
#import "Home.h"
#import "Profile.h"
#import "Inventory.h"
#import "Customers.h"
#import "Stores.h"
#import "Reports.h"
#import "Contacts.h"
#import "DataBaseManager.h"
#import "general data.h"
#import "ServersyncClass.h"
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@interface Employees ()

@end

@implementation Employees
{
    ServersyncClass *serverSyncClassObject;
     general_data *generalDataObject;
    Employeepagination *employeepaginationObject;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    generalDataObject =[general_data new];
    [generalDataObject  GetuserDataVariablesMethod];
    serverSyncClassObject=[ServersyncClass new];
    employeepaginationObject=[Employeepagination new];
    
    [NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:serverSyncClassObject withObject:nil];
   
      //appDelegate =  (AppDelegate *)[UIApplication sharedApplication].delegate;
    [super viewDidLoad];
    
    //[NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:[ServersyncClass sharedInstance] withObject:nil];
    
    y=0;
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        y=y+20;
        
        
    }
    CGFloat width,height;
    width=self.view.frame.size.width;
    height=self.view.frame.size.height;
    // //NSLog(@" %f,%f",width,height);
    
    
    
    backgroundcolorview=[[UIView alloc]init];
    backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
    [backgroundcolorview  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background" ofType:@"jpg"]]]];
    
    [self.view addSubview:backgroundcolorview];
    
    // [ContactsBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"contactsactive" ofType:@"png"]] forState:UIControlStateNormal];
    
    sidemenu=[[UIView alloc]init];
    sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
    //sidemenu.hidden=YES;
    //[sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bluecolorstrip.jpg"]]];
    [sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluecolorstrip" ofType:@"jpg"]]]];
    
    
    NSString *pagetitle;
    pagetitle=@"Employees";
    
    navBar = [[UINavigationBar alloc] init];
    navBar.frame=CGRectMake(0, 0,width , 50.0);
    
    [navBar setBackgroundImage:[UIImage imageNamed:@"logo-login-bg-short.png"] forBarMetrics:UIBarMetricsDefault];
    
    //[navBar setBackgroundColor:[UIColor blackColor]];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    titleLabel.font=[UIFont boldSystemFontOfSize:30.0];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.text =pagetitle;
    [self.navigationItem setTitleView:titleLabel];
    
    
    //navItem.title = pagetitle;
    [navBar pushNavigationItem:self.navigationItem animated:false];
    
    [backgroundcolorview addSubview:navBar];
    
    
    menubutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [menubutton setFrame:CGRectMake(0,0,50,50)];
    [menubutton addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    [menubutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow" ofType:@"png"]] forState:UIControlStateNormal];
    [navBar addSubview:menubutton];
    
    
    logoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [logoBtn setFrame:CGRectMake(60,0,250,50)];
    // [logoBtn addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logoBtn setImage:[UIImage imageNamed:@"headeraonelogo.png"] forState:UIControlStateNormal];
    [logoBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"headeraonelogo" ofType:@"png"]] forState:UIControlStateNormal];
    
    [navBar addSubview:logoBtn];
    sationLbl=[[UILabel alloc] init];
    
    sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
    
    [sationLbl setFont:[UIFont systemFontOfSize:13.0f]];
    [sationLbl setBackgroundColor:[UIColor clearColor]];
    [sationLbl setTextColor:[UIColor blackColor]];
    [sationLbl setText:@"Station No:1"];
    sationLbl.lineBreakMode = NSLineBreakByWordWrapping;
    sationLbl.numberOfLines = 2;
    [sationLbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:sationLbl];
    
    
    EmpIdlbl=[[UILabel alloc] init];
    EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
    
    [EmpIdlbl setFont:[UIFont systemFontOfSize:13.0f]];
    [EmpIdlbl setBackgroundColor:[UIColor clearColor]];
    [EmpIdlbl setTextColor:[UIColor blackColor]];
    [EmpIdlbl setText:[NSString stringWithFormat:@"Employee Id: %@",[generalDataObject  userID]]];
    EmpIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    // EmpIdlbl.numberOfLines = 2;
    [EmpIdlbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:EmpIdlbl];
    
    
    Timelbl=[[UILabel alloc] init];
    
    Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
    
    [Timelbl setFont:[UIFont systemFontOfSize:13.0f]];
    [Timelbl setBackgroundColor:[UIColor clearColor]];
    [Timelbl setTextColor:[UIColor blackColor]];
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    //Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    
    // timer is set & will be triggered each second
    //[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(showTime) userInfo:nil repeats:YES];
    Timelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Timelbl.numberOfLines = 2;
    [Timelbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:Timelbl];
    
    p=1;
    @autoreleasepool {
        for (int i=0; i< 10; i++)
        {
            
            categorybutton = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [categorybutton setFrame:CGRectMake(0,p,170,40)];
            [categorybutton addTarget:self action:@selector(categotybuttonclicked:) forControlEvents:UIControlEventTouchUpInside];
            categorybutton.tag=i;
            if (categorybutton.tag == 0)
            {
                [categorybutton setImage:[UIImage imageNamed:@"posnormal2.png"] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 1)
            {
                [categorybutton setImage:[UIImage imageNamed:@"profilenormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 2)
            {
                [categorybutton setImage:[UIImage imageNamed:@"inventorynormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 3)
            {
                [categorybutton setImage:[UIImage imageNamed:@"customernormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 4)
            {
                [categorybutton setImage:[UIImage imageNamed:@"employeeactive2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 5)
            {
                [categorybutton setImage:[UIImage imageNamed:@"settingsnormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 6)
            {
                [categorybutton setImage:[UIImage imageNamed:@"reportsnormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 7)
            {
                [categorybutton setImage:[UIImage imageNamed:@"contactsnormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 8)
            {
                [categorybutton setImage:[UIImage imageNamed:@"storesnormal.png"] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 9)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"bluecolorstrip.jpg"] forState:UIControlStateNormal];
            }
            [sidemenu addSubview:categorybutton];
            p=p+categorybutton.frame.size.height;
        }
    }
   
    
    mainview=[[UIView alloc]init];
    mainview.frame=CGRectMake(20,60,width-40,height-200);
    [mainview setBackgroundColor:[UIColor grayColor]];
    [mainview  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"hqbackground69opacity.png"]]];
    [backgroundcolorview addSubview:mainview];
    
    
    logoimageview=[[UIImageView alloc]init];
    logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
    [logoimageview setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aoneposlogo" ofType:@"png"]]];
    [self.view addSubview:logoimageview];
    
    helpiconButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [helpiconButton setFrame:CGRectMake(width-180,y+40,70,70)];
    [helpiconButton addTarget:self action:@selector(helpiconclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[helpiconButton setImage:[UIImage imageNamed:@"helpicon.png"] forState:UIControlStateNormal];
    [helpiconButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"helpicon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [self.view addSubview:helpiconButton];
    logouticonButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [logouticonButton setFrame:CGRectMake(width-100,y+40,70,70)];
    [logouticonButton addTarget:self action:@selector(logoutButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logouticonButton setImage:[UIImage imageNamed:@"logoutbutton.png"] forState:UIControlStateNormal];
    [logouticonButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logoutbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [self.view addSubview:logouticonButton];
    
    
    //Employee view
    
   
    if(!DepartmentsArray)
    DepartmentsArray=[[NSMutableArray alloc]initWithObjects:@"Sales",@"Management",@"Accounting", nil];
    
    
    EmployeesBackView=[[UIView alloc]init];
    EmployeesBackView.frame=CGRectMake(10, 0, mainview.frame.size.width-20, (mainview.frame.size.height));
    [EmployeesBackView setBackgroundColor:[UIColor whiteColor]];
    [EmployeesBackView.layer setBorderWidth: 1.0];
    [EmployeesBackView.layer setCornerRadius:8.0f];
    [EmployeesBackView.layer setMasksToBounds:YES];
    [EmployeesBackView.layer setBorderColor:[[UIColor blackColor] CGColor]];
    
    EmployeesBackView.layer.cornerRadius=8;
    [mainview addSubview:EmployeesBackView];
    
    AddEmployeeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [AddEmployeeBtn setTitle:@"Add Employee" forState:UIControlStateNormal];
    CGFloat addbuttonwidth=(EmployeesBackView.frame.size.width-10)/2;
    AddEmployeeBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
    [AddEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    
    
    //addtaxBtn.layer.cornerRadius=8;
    [AddEmployeeBtn addTarget:self action:@selector(AddEmployee) forControlEvents:UIControlEventTouchUpInside];
    [EmployeesBackView addSubview:AddEmployeeBtn];
    
    EditEmployeeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [EditEmployeeBtn setTitle:@"View and Edit Employee" forState:UIControlStateNormal];
    EditEmployeeBtn.frame=CGRectMake(AddEmployeeBtn.frame.size.width, 10, addbuttonwidth, 40);
    //editTaxButton.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [EditEmployeeBtn setBackgroundColor:[UIColor whiteColor]];
    [EditEmployeeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [EditEmployeeBtn addTarget:self action:@selector(EditEmployee) forControlEvents:UIControlEventTouchUpInside];
    [EmployeesBackView addSubview: EditEmployeeBtn];
    
    AddEmployeesView=[[UIScrollView alloc]init];
    
    AddEmployeesView.frame=CGRectMake(10, AddEmployeeBtn.frame.size.height+10, EmployeesBackView.frame.size.width-20, EmployeesBackView.frame.size.height-20-AddEmployeeBtn.frame.size.height);
    AddEmployeesView.contentSize=CGSizeMake(EmployeesBackView.frame.size.width-20,  EmployeesBackView.frame.size.height+100);
    [AddEmployeesView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    // AddEmployeesView.layer.cornerRadius=8;
    [EmployeesBackView addSubview:AddEmployeesView];
    
    
    CGFloat customerW=(AddEmployeesView.frame.size.width)/4;
    CGFloat r=(customerW/2)+20;
    
    Departmentlbl=[[UILabel alloc] init];
    Departmentlbl.frame=CGRectMake(r-90, 30,customerW, 50);
    
    [Departmentlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Departmentlbl setBackgroundColor:[UIColor clearColor]];
    [Departmentlbl setTextColor:[UIColor whiteColor]];
    [Departmentlbl setText:@"Department"];
    Departmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    Departmentlbl.numberOfLines = 2;
    [Departmentlbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:Departmentlbl];
    
    DepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DepartmentBtn.frame=CGRectMake(customerW-5, 35,customerW, 40);
    [DepartmentBtn addTarget:self action:@selector(DepartmentBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [DepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    //[DepartmentBtn setTitle:cardType forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [AddEmployeesView addSubview:DepartmentBtn];
    
    DepartmentListTable = [[UITableView alloc] initWithFrame:CGRectMake(customerW-5, 75,customerW, 100) style:UITableViewStylePlain];
    DepartmentListTable.backgroundColor=[UIColor whiteColor];
    DepartmentListTable.delegate = self;
    DepartmentListTable.dataSource = self;
    DepartmentListTable.scrollEnabled = YES;
    DepartmentListTable.hidden=YES;
    [DepartmentListTable.layer setBorderWidth: 1.0];
    [DepartmentListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [AddEmployeesView addSubview:DepartmentListTable];
    
    EmployeeIdLbl=[[UILabel alloc] init];
    EmployeeIdLbl.frame=CGRectMake(r-90, 90,customerW, 50);
    [EmployeeIdLbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EmployeeIdLbl setBackgroundColor:[UIColor clearColor]];
    [EmployeeIdLbl setTextColor:[UIColor whiteColor]];
    [EmployeeIdLbl setText:@"Employee ID"];
    EmployeeIdLbl.lineBreakMode = NSLineBreakByWordWrapping;
    EmployeeIdLbl.numberOfLines = 2;
    [EmployeeIdLbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:EmployeeIdLbl];
    
    EmployeeIdField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EmployeeIdField.frame=CGRectMake(customerW-5, 95,customerW, 40);
    EmployeeIdField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EmployeeIdField.leftView = paddingview2;
    EmployeeIdField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EmployeeIdField.leftViewMode = UITextFieldViewModeAlways;
    [EmployeeIdField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [EmployeeIdField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddEmployeesView addSubview:EmployeeIdField];
    
    
    
    Passwordlbl=[[UILabel alloc] init];
    Passwordlbl.frame=CGRectMake(r-90, 150,customerW, 50);
    [Passwordlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Passwordlbl setBackgroundColor:[UIColor clearColor]];
    [Passwordlbl setTextColor:[UIColor whiteColor]];
    [Passwordlbl setText:@"Password"];
    Passwordlbl.lineBreakMode = NSLineBreakByWordWrapping;
    Passwordlbl.numberOfLines = 2;
    [Passwordlbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:Passwordlbl];
    
    PasswordField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    PasswordField.frame=CGRectMake(customerW-5, 155,customerW, 40);
    PasswordField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    PasswordField.leftView = paddingview3;
    PasswordField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    PasswordField.leftViewMode = UITextFieldViewModeAlways;
    [PasswordField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [PasswordField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddEmployeesView addSubview:PasswordField];
    
    Displaynamelbl=[[UILabel alloc] init];
    Displaynamelbl.frame=CGRectMake(r-90, 210,customerW, 50);
    
    [Displaynamelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Displaynamelbl setBackgroundColor:[UIColor clearColor]];
    [Displaynamelbl setTextColor:[UIColor whiteColor]];
    [Displaynamelbl setText:@"DisplayName"];
    Displaynamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Displaynamelbl.numberOfLines = 2;
    [Displaynamelbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:Displaynamelbl];
    
    DisplaynameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    DisplaynameField.frame=CGRectMake(customerW-5, 215,customerW, 40);
    DisplaynameField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    DisplaynameField.leftView = paddingview4;
    DisplaynameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DisplaynameField.leftViewMode = UITextFieldViewModeAlways;
    [DisplaynameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [DisplaynameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddEmployeesView addSubview:DisplaynameField];
    
    
    CardSwipeIdlbl=[[UILabel alloc] init];
    CardSwipeIdlbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 30,customerW, 50);
    
    [CardSwipeIdlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [CardSwipeIdlbl setBackgroundColor:[UIColor clearColor]];
    [CardSwipeIdlbl setTextColor:[UIColor whiteColor]];
    [CardSwipeIdlbl setText:@"Card Swipe ID"];
    CardSwipeIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    CardSwipeIdlbl.numberOfLines = 2;
    [CardSwipeIdlbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:CardSwipeIdlbl];
    
    CardSwipeIdField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    CardSwipeIdField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 35,customerW, 40);
    CardSwipeIdField.delegate=self;
    UIView *paddingview6=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    CardSwipeIdField.leftView = paddingview6;
    CardSwipeIdField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    CardSwipeIdField.leftViewMode = UITextFieldViewModeAlways;
    [CardSwipeIdField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [CardSwipeIdField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddEmployeesView addSubview:CardSwipeIdField];
    
    CustomerLbl=[[UILabel alloc] init];
    CustomerLbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 90,customerW, 50);
    [CustomerLbl setFont:[UIFont systemFontOfSize:22.0f]];
    [CustomerLbl setBackgroundColor:[UIColor clearColor]];
    [CustomerLbl setTextColor:[UIColor whiteColor]];
    [CustomerLbl setText:@"Customer"];
    CustomerLbl.lineBreakMode = NSLineBreakByWordWrapping;
    CustomerLbl.numberOfLines = 2;
    [CustomerLbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:CustomerLbl];
    
    CustomerField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    CustomerField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 95,customerW, 40);
    CustomerField.delegate=self;
    UIView *paddingview7=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    CustomerField.leftView = paddingview7;
    CustomerField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    CustomerField.leftViewMode = UITextFieldViewModeAlways;
    [CustomerField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [CustomerField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddEmployeesView addSubview:CustomerField];
    
    Houlrywagelbl=[[UILabel alloc] init];
    Houlrywagelbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 150,customerW, 50);
    [Houlrywagelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Houlrywagelbl setBackgroundColor:[UIColor clearColor]];
    [Houlrywagelbl setTextColor:[UIColor whiteColor]];
    [Houlrywagelbl setText:@"Houly Wage"];
    Houlrywagelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Houlrywagelbl.numberOfLines = 2;
    [Houlrywagelbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:Houlrywagelbl];
    
    HoulrywageField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    HoulrywageField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 155,customerW, 40);
    HoulrywageField.delegate=self;
    UIView *paddingview8=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    HoulrywageField.leftView = paddingview8;
    HoulrywageField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    HoulrywageField.leftViewMode = UITextFieldViewModeAlways;
    [HoulrywageField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [HoulrywageField setAutocorrectionType:UITextAutocorrectionTypeNo];
    HoulrywageField.keyboardType=UIKeyboardTypeNumberPad;
    [AddEmployeesView addSubview:HoulrywageField];
    
    Disablelbl=[[UILabel alloc] init];
    Disablelbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 210,customerW+80, 50);
    [Disablelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Disablelbl setBackgroundColor:[UIColor clearColor]];
    [Disablelbl setTextColor:[UIColor whiteColor]];
    
    [Disablelbl setText:@"Disable this Employee"];
    
    [Disablelbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:Disablelbl];
    
    disableBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    disableBtn.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+Disablelbl.frame.size.width, 220,30, 30);
    [disableBtn addTarget:self action:@selector(DisableBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [disableBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [disableBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [disableBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [AddEmployeesView addSubview:disableBtn];
    
    administrativelbl=[[UILabel alloc] init];
    administrativelbl.frame=CGRectMake(r-90, 270,customerW+100, 50);
    [administrativelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [administrativelbl setBackgroundColor:[UIColor clearColor]];
    [administrativelbl setTextColor:[UIColor whiteColor]];
    
    [administrativelbl setText:@"Administrative Card Access"];
    
    [administrativelbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:administrativelbl];
    
    administrativeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    administrativeBtn.frame=CGRectMake(r-80+administrativelbl.frame.size.width, 280,30, 30);
    [administrativeBtn addTarget:self action:@selector(AdministrativeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [administrativeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [administrativeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [administrativeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [AddEmployeesView addSubview:administrativeBtn];
    
    
    TakeccTipslbl=[[UILabel alloc] init];
    TakeccTipslbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 250,customerW+80, 100);
    [TakeccTipslbl setFont:[UIFont systemFontOfSize:22.0f]];
    [TakeccTipslbl setBackgroundColor:[UIColor clearColor]];
    [TakeccTipslbl setTextColor:[UIColor whiteColor]];
    
    [TakeccTipslbl setText:@"Take CC Tips in Cash at End of Shift"];
    TakeccTipslbl.lineBreakMode = NSLineBreakByWordWrapping;
    TakeccTipslbl.numberOfLines = 2;
    [TakeccTipslbl setTextAlignment:NSTextAlignmentLeft];
    [AddEmployeesView addSubview:TakeccTipslbl];
    
    TakeccTipsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    TakeccTipsBtn.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+TakeccTipslbl.frame.size.width+20, 280,30, 30);
    [TakeccTipsBtn addTarget:self action:@selector(TakecctipsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [TakeccTipsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [TakeccTipsBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [TakeccTipsBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [AddEmployeesView addSubview:TakeccTipsBtn];
    
    
    CGFloat wdth=(AddEmployeesView.frame.size.width)/5;
    CGFloat xvalue=wdth/4;
    @autoreleasepool {
        for (int k=0; k<4; k++)
        {
            EmployeeInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            NSArray *array2=[[NSArray alloc]initWithObjects:@"Permissions",@"Personal Info",@"Payroll Info",@"Store Info",nil];
            [EmployeeInfoBtn setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
            [EmployeeInfoBtn setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
            EmployeeInfoBtn.frame=CGRectMake(xvalue,340,wdth+5, 40);
            
            [EmployeeInfoBtn addTarget:self action:@selector(infoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
            EmployeeInfoBtn.tag=k+100;
            [EmployeeInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            [AddEmployeesView addSubview:EmployeeInfoBtn];
            xvalue=xvalue+wdth+15;
            
        }
    }
   
    SaveEmployeeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    SaveEmployeeBtn.frame=CGRectMake(customerW+100, 420, 80, 30);
    [SaveEmployeeBtn addTarget:self action:@selector(SaveEmployeeData) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [SaveEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [SaveEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [AddEmployeesView addSubview:SaveEmployeeBtn];
    
    CancelEmployeeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CancelEmployeeBtn.frame=CGRectMake(customerW+220, 420, 80, 30);
    [CancelEmployeeBtn addTarget:self action:@selector(CancelEmployeeData) forControlEvents:UIControlEventTouchUpInside];
    [CancelEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CancelEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [AddEmployeesView addSubview:CancelEmployeeBtn];
    
      NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password FROM employee_table"];
    
    NSMutableArray *employeesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesArray];
    
   
    NSMutableArray *rdarray=employeesArray;
    
    //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [employeepaginationObject   setCompleteresultset:rdarray];
    
    [employeepaginationObject    paginationinitializer:rdarray :20];
    
    //[employeepaginationObject   paginationsegment].tintColor=[UIColor whiteColor];
    [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
    
    [[employeepaginationObject   paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [employeepaginationObject   paginationsegment].selectedSegmentIndex=selectedsegindex;
   [employeepaginationObject   activateResults:selectedsegindex];
    
    
    EditEmployeeTable=[[UITableView alloc]init];
    [EditEmployeeTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditEmployeeTable.frame=CGRectMake(10, AddEmployeeBtn.frame.size.height+50, EmployeesBackView.frame.size.width-20, EmployeesBackView.frame.size.height-20-AddEmployeeBtn.frame.size.height-40);
    SelectedStoredataArray=[[NSMutableArray alloc]init];
    //editProductTable.contentSize = CGSizeMake(ProductView.frame.size.width+1000, ProductView.frame.size.height+1000);
    EditEmployeeTable.delegate=self;
    EditEmployeeTable.dataSource=self;
  
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    [super viewWillAppear:YES];
    
    [EmployeeIdField setReturnKeyType:UIReturnKeyNext];
    [PasswordField setReturnKeyType:UIReturnKeyNext];
    [DisplaynameField setReturnKeyType:UIReturnKeyNext];
    [CardSwipeIdField setReturnKeyType:UIReturnKeyNext];
    [CustomerField setReturnKeyType:UIReturnKeyNext];
    // [DisplaynameField setReturnKeyType:UIReturnKeyNext];
    [HoulrywageField setReturnKeyType:UIReturnKeyDone];
    inventory=@"";reports=@"";settings=@"";allowexit=@"";deleteitems=@"";endTransactions=@"";forceCreditcard=@"";
    customers=@"";invoicediscounts=@"";pricechnages=@"";payouts=@"";voidinvoices=@"";hold=@"";endcash=@"";
    Exclude=@"";federal=@"";federalAmount=@"";stateallowances=@"";stateAmount=@"";credits=@"";
    Exempt=@"";Filling=@"";
    Disable=@"";administrative=@"";Cctips=@"";
    
    Cctips=@"no";
    Disable=@"no";
    administrative=@"no";
    inventory=@"no";
    reports=@"no";
    settings=@"no";
    allowexit=@"no";
    deleteitems=@"no";
    endTransactions=@"no";
    forceCreditcard=@"no";
    
    customers=@"no";
    invoicediscounts=@"no";
    pricechnages=@"no";
    payouts=@"no";
    voidinvoices=@"no";
    hold=@"no";
    endcash=@"no";
    
    Name=@"";
    ID=@"";
    Email=@"";
    Phonenumber=@"";
    Birthday=@"";
    Address=@"";
    City=@"";
    Country=@"";
    state=@"";
    Zipcode=@"";
    federal=@"",federalAmount=@"",stateallowances=@"",stateAmount=@"",credits=@"",Filling=@"",Exempt=@"",Exclude=@"";
    
     helpiconButton.hidden=YES;
     // Do any additional setup after loading the view from its nib.
}
-(void)viewWillAppear:(BOOL)animated
{
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    [super viewWillAppear:animated];
    
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == EmployeeIdField) {
		[textField resignFirstResponder];
        [PasswordField becomeFirstResponder];
    }
    else if (textField == PasswordField) {
		[textField resignFirstResponder];
        [DisplaynameField becomeFirstResponder];
    }
    else if (textField == DisplaynameField) {
		[textField resignFirstResponder];
        [CardSwipeIdField becomeFirstResponder];
    }
    else if (textField == CardSwipeIdField) {
		[textField resignFirstResponder];
        [CustomerField becomeFirstResponder];
    }
    else if (textField == CustomerField)
    {
		[textField resignFirstResponder];
        [HoulrywageField becomeFirstResponder];
    }
    else if (textField == HoulrywageField)
    {
		[textField resignFirstResponder];
        
    }
    return YES;
    
}
-(void)showTime
{
    
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    // Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    //Timelbl.text=[[NSDate date] description];
    
    
}

-(void)AddEmployee
{
    Name=@"";
    ID=@"";
    Email=@"";
    Phonenumber=@"";
    Birthday=@"";
    Address=@"";
    City=@"";
    Country=@"";
    state=@"";
    Zipcode=@"";
    
    inventory=@"";reports=@"";settings=@"";allowexit=@"";deleteitems=@"";endTransactions=@"";forceCreditcard=@"";
    customers=@"";invoicediscounts=@"";pricechnages=@"";payouts=@"";voidinvoices=@"";hold=@"";endcash=@"";
    Exclude=@"";federal=@"";federalAmount=@"";stateallowances=@"";stateAmount=@"";credits=@"";
    Exempt=@"";Filling=@"";
    Disable=@"";administrative=@"";Cctips=@"";
    [EditEmployeeBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [AddEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    [EditEmployeeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [AddEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    // [edittaxTable removeFromSuperview];
    
    [[employeepaginationObject   paginationsegment]  removeFromSuperview];
    [EditEmployeeTable removeFromSuperview];
    [EmployeesBackView addSubview:AddEmployeesView];
    if (!SelectedStoredataArray) {
        SelectedStoredataArray=[[NSMutableArray alloc]init];
        SeleCtedStoreIdsArray=[[NSMutableArray alloc]init];
    }
 
    [EmDepartmentsArray removeAllObjects];
    [EmployeeIdsArray removeAllObjects];
    [passwordsArray removeAllObjects];
    [DisplayNamesArray removeAllObjects];
    
    [cardswipeidsArray removeAllObjects];
    [EmCustomersArray removeAllObjects];
    [houlrywagesArray removeAllObjects];
    
    [disablesArray removeAllObjects];
    [administativesArray removeAllObjects];
    [CctipsArray removeAllObjects];
    
    [NamesArray removeAllObjects];
    [IDsArray removeAllObjects];
   [EmailsArray removeAllObjects];
    [PhonenumbersArray removeAllObjects];
    
    [BirthdaysArray removeAllObjects];
    [AddresssArray removeAllObjects];
    [CitysArray removeAllObjects];
    
    [CountrysArray removeAllObjects];
    [statesArray removeAllObjects];
    [ZipcodesArray removeAllObjects];
    
    [inventorysArray removeAllObjects];
    [reportssArray removeAllObjects];
    [settingssArray removeAllObjects];
    [allowexitsArray removeAllObjects];
    
    [deleteitemssArray removeAllObjects];
    [endTransactionssArray removeAllObjects];
    [forceCreditcardsArray removeAllObjects];
    
    [customerssArray removeAllObjects];
    [invoicediscountssArray removeAllObjects];
    [pricechnagessArray removeAllObjects];
    
   [payoutssArray removeAllObjects];
    [voidinvoicessArray removeAllObjects];
    [holdsArray removeAllObjects];
    [endcashsArray removeAllObjects];
    
    EmDepartmentsArray=nil;
    EmployeeIdsArray=nil;
    passwordsArray=nil;
    DisplayNamesArray=nil;
    
    cardswipeidsArray=nil;
    EmCustomersArray=nil;
    houlrywagesArray=nil;
    
    disablesArray=nil;
    administativesArray=nil;
    CctipsArray=nil;
    
    NamesArray=nil;
    IDsArray=nil;
    EmailsArray=nil;
    PhonenumbersArray=nil;
    
    BirthdaysArray=nil;
    AddresssArray=nil;
    CitysArray=nil;
    
    CountrysArray=nil;
    statesArray=nil;
    ZipcodesArray=nil;
    
    inventorysArray=nil;
    reportssArray=nil;
    settingssArray=nil;
    allowexitsArray=nil;
    
    deleteitemssArray=nil;
    endTransactionssArray=nil;
    forceCreditcardsArray=nil;
    
    customerssArray=nil;
    invoicediscountssArray=nil;
    pricechnagessArray=nil;
    
    payoutssArray=nil;
    voidinvoicessArray=nil;
    holdsArray=nil;
    endcashsArray=nil;

}
-(void)EditEmployee
{
  [AddEmployeeBtn setBackgroundColor:[UIColor whiteColor]];
    [AddEmployeeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    //addtaxBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [AddEmployeeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [AddEmployeeBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
  
    NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password FROM employee_table"];
    
    NSMutableArray *employeesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesArray];

  NSMutableArray *rdarray=employeesArray;
    
    //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [employeepaginationObject   setCompleteresultset:rdarray];
    
    [employeepaginationObject    paginationinitializer:rdarray :20];
    
   // [employeepaginationObject   paginationsegment].tintColor=[UIColor whiteColor];
    [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
    
    [[employeepaginationObject   paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [employeepaginationObject   paginationsegment].selectedSegmentIndex=selectedsegindex;
  [employeepaginationObject   activateResults:selectedsegindex];
   [EmployeesBackView addSubview:[employeepaginationObject   paginationsegment]];
    [self GetEmployeeDataMethod];
     [AddEmployeesView removeFromSuperview];
   // //NSLog(@"names array %@",NamesArray);
    [EmployeesBackView addSubview:EditEmployeeTable];
}

-(void) GetEmployeeDataMethod
{
 
    
     NSString *querySQL = [NSString stringWithFormat: @"SELECT emp_name,emp_id,emp_email,emp_phone,emp_birth,emp_address,emp_city,emp_country,emp_state,emp_postal,employee_employee_id,unique_id FROM employee_personal"];
    NSMutableArray *employeesprsonalArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesprsonalArray];

    NSString *permissionsQuery = [NSString stringWithFormat: @"SELECT emp_inventory,emp_customers,emp_reports,emp_discounts,emp_settings,emp_price_hanges,emp_allow_exit,emp_vendor_payouts,emp_delete_items,emp_void_invoices,emp_transactions,emp_holdprint,emp_creditcards,emp_endcash,employee_employee_id,unique_id,created_timestamp,modified_timestamp FROM employee_permissions"];
    NSMutableArray *employeespermissionsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:permissionsQuery resultsArray:employeespermissionsArray];
    
    NSString *payrollQuery = [NSString stringWithFormat: @"SELECT federal,amount,statea,stateAmount,credits,filingstatus,exempt,excludeCheck,employee_employee_id,unique_id,created_timestamp,modified_timestamp FROM employee_payroll"];
    NSMutableArray *employeespayrollsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:payrollQuery resultsArray:employeespayrollsArray];
   

   
        EmDepartmentsArray=[[NSMutableArray alloc]init];
        EmployeeIdsArray=[[NSMutableArray alloc]init];
        passwordsArray=[[NSMutableArray alloc]init];
        DisplayNamesArray=[[NSMutableArray alloc]init];
        
        cardswipeidsArray=[[NSMutableArray alloc]init];
        EmCustomersArray=[[NSMutableArray alloc]init];
        houlrywagesArray=[[NSMutableArray alloc]init];
        
        disablesArray=[[NSMutableArray alloc]init];
        administativesArray=[[NSMutableArray alloc]init];
        CctipsArray=[[NSMutableArray alloc]init];
        
    

        NamesArray=[[NSMutableArray alloc]init];
        IDsArray=[[NSMutableArray alloc]init];
        EmailsArray=[[NSMutableArray alloc]init];
        PhonenumbersArray=[[NSMutableArray alloc]init];
        
        BirthdaysArray=[[NSMutableArray alloc]init];
        AddresssArray=[[NSMutableArray alloc]init];
        CitysArray=[[NSMutableArray alloc]init];
        
        CountrysArray=[[NSMutableArray alloc]init];
        statesArray=[[NSMutableArray alloc]init];
        ZipcodesArray=[[NSMutableArray alloc]init];
        

    
  
        inventorysArray=[[NSMutableArray alloc]init];
        reportssArray=[[NSMutableArray alloc]init];
        settingssArray=[[NSMutableArray alloc]init];
        allowexitsArray=[[NSMutableArray alloc]init];
        
        deleteitemssArray=[[NSMutableArray alloc]init];
        endTransactionssArray=[[NSMutableArray alloc]init];
        forceCreditcardsArray=[[NSMutableArray alloc]init];
        
        customerssArray=[[NSMutableArray alloc]init];
        invoicediscountssArray=[[NSMutableArray alloc]init];
        pricechnagessArray=[[NSMutableArray alloc]init];
        
        payoutssArray=[[NSMutableArray alloc]init];
        voidinvoicessArray=[[NSMutableArray alloc]init];
        holdsArray=[[NSMutableArray alloc]init];
        endcashsArray=[[NSMutableArray alloc]init];
   
        ExcludesArray=[[NSMutableArray alloc]init];
        federalsArray=[[NSMutableArray alloc]init];
        federalAmountsArray=[[NSMutableArray alloc]init];
        stateallowancessArray=[[NSMutableArray alloc]init];
        
        stateAmountsArray=[[NSMutableArray alloc]init];
        DataExemptsArray=[[NSMutableArray alloc]init];
        DataFillingsArray=[[NSMutableArray alloc]init];
        creditssArray=[[NSMutableArray alloc]init];
    

    @autoreleasepool {
        for (NSDictionary *myDict in [employeepaginationObject   activeresultset])
        {
            [EmDepartmentsArray addObject:[myDict objectForKey:@"employee_department"]];
            [EmployeeIdsArray addObject:[myDict objectForKey:@"employee_employee_id"]];
            [passwordsArray addObject:[myDict objectForKey:@"employee_password"]];
            [DisplayNamesArray addObject:[myDict objectForKey:@"employee_display_name"]];
            
            [cardswipeidsArray addObject:[myDict objectForKey:@"employee_card_swipeid"]];
            [EmCustomersArray addObject:[myDict objectForKey:@"employee_customer"]];
            [houlrywagesArray addObject:[myDict objectForKey:@"employee_hourly_wage"]];
            
            [disablesArray addObject:[myDict objectForKey:@"employee_disable"]];
            [administativesArray addObject:[myDict objectForKey:@"employee_admin_card"]];
            [CctipsArray addObject:[myDict objectForKey:@"employee_cc_tips"]];
            
            
        }
    }
  
    @autoreleasepool {
        for (NSDictionary *myDict in employeesprsonalArray)
        {
            [NamesArray addObject:[myDict objectForKey:@"emp_name"]];
            [IDsArray addObject:[myDict objectForKey:@"emp_id"]];
            [EmailsArray addObject:[myDict objectForKey:@"emp_email"]];
            [PhonenumbersArray addObject:[myDict objectForKey:@"emp_phone"]];
            
            [BirthdaysArray addObject:[myDict objectForKey:@"emp_birth"]];
            [AddresssArray addObject:[myDict objectForKey:@"emp_address"]];
            [CitysArray addObject:[myDict objectForKey:@"emp_city"]];
            
            [CountrysArray addObject:[myDict objectForKey:@"emp_country"]];
            [statesArray addObject:[myDict objectForKey:@"emp_state"]];
            [ZipcodesArray addObject:[myDict objectForKey:@"emp_postal"]];
    
        }
    }
  
    @autoreleasepool {
        for (NSDictionary *myDict in employeespermissionsArray)
        {
            [inventorysArray addObject:[myDict objectForKey:@"emp_inventory"]];
            [reportssArray addObject:[myDict objectForKey:@"emp_reports"]];
            [settingssArray addObject:[myDict objectForKey:@"emp_settings"]];
            [allowexitsArray addObject:[myDict objectForKey:@"emp_allow_exit"]];
            
            [deleteitemssArray addObject:[myDict objectForKey:@"emp_delete_items"]];
            [endTransactionssArray addObject:[myDict objectForKey:@"emp_transactions"]];
            [forceCreditcardsArray addObject:[myDict objectForKey:@"emp_creditcards"]];
            
            [customerssArray addObject:[myDict objectForKey:@"emp_customers"]];
            [invoicediscountssArray addObject:[myDict objectForKey:@"emp_discounts"]];
            [pricechnagessArray addObject:[myDict objectForKey:@"emp_price_hanges"]];
            
            [payoutssArray addObject:[myDict objectForKey:@"emp_vendor_payouts"]];
            [voidinvoicessArray addObject:[myDict objectForKey:@"emp_void_invoices"]];
            [holdsArray addObject:[myDict objectForKey:@"emp_holdprint"]];
            [endcashsArray addObject:[myDict objectForKey:@"emp_endcash"]];
            
            
        }
    }
 
    @autoreleasepool {
        for (NSDictionary *myDict in employeespayrollsArray)
        {
            [ExcludesArray addObject:[myDict objectForKey:@"excludeCheck"]];
            [federalsArray addObject:[myDict objectForKey:@"federal"]];
            [federalAmountsArray addObject:[myDict objectForKey:@"amount"]];
            [stateallowancessArray addObject:[myDict objectForKey:@"statea"]];
            
            [stateAmountsArray addObject:[myDict objectForKey:@"stateAmount"]];
            [DataExemptsArray addObject:[myDict objectForKey:@"exempt"]];
            [DataFillingsArray addObject:[myDict objectForKey:@"filingstatus"]];
            [creditssArray addObject:[myDict objectForKey:@"credits"]];
        }
    }
   
    

}
-(void)DepartmentBtnClicked
{
    if (DepartmentListTable.hidden==1)
    {
        PasswordField.hidden=YES;
          EmployeeIdField.hidden=YES;
        DepartmentListTable.hidden=NO;
       
        
    }else if (DepartmentListTable.hidden==0){
          PasswordField.hidden=NO;
         EmployeeIdField.hidden=NO;
        [DepartmentListTable setHidden:YES];
       
    }
    
}
-(void)CancelEmployeeData
{
    EmployeeIdField.text=@"";
    CustomerField.text=@"";
    PasswordField.text=@"";
    DisplaynameField.text=@"";
    CardSwipeIdField.text=@"";
    HoulrywageField.text=@"";
}
-(void)DisableBtnClicked
{
    if (disableBtn.selected){
        [disableBtn setSelected:NO];
        Disable=@"no";
    }else if(!disableBtn.selected){
        [disableBtn setSelected:YES];
           Disable=@"yes";
    }
    
}
-(void)ExcludeBtnClicked
{
    if (ExcludeBtn.selected){
        [ExcludeBtn setSelected:NO];
        Exclude=@"no";
    }else if(!ExcludeBtn.selected){
        [ExcludeBtn setSelected:YES];
        Exclude=@"yes";
    }
}
-(void)TakecctipsBtnClicked
{
    if (TakeccTipsBtn.selected){
        [TakeccTipsBtn setSelected:NO];
        Cctips=@"no";
    }else if(!TakeccTipsBtn.selected){
        [TakeccTipsBtn setSelected:YES];
        Cctips=@"yes";
    }
}
-(void)AdministrativeBtnClicked
{
    if (administrativeBtn.selected){
        [administrativeBtn setSelected:NO];
           administrative=@"no";
        
        inventory=@"no";
        reports=@"no";
        settings=@"no";
        allowexit=@"no";
        deleteitems=@"no";
        endTransactions=@"no";
        forceCreditcard=@"no";

        customers=@"no";
        invoicediscounts=@"no";
        pricechnages=@"no";
        payouts=@"no";
        voidinvoices=@"no";
        hold=@"no";
        endcash=@"no";
        
    }else if(!administrativeBtn.selected){
        [administrativeBtn setSelected:YES];
         administrative=@"yes";
        inventory=@"yes";
        reports=@"yes";
        settings=@"yes";
        allowexit=@"yes";
        deleteitems=@"yes";
        endTransactions=@"yes";
        forceCreditcard=@"yes";
        
        customers=@"yes";
        invoicediscounts=@"yes";
        pricechnages=@"yes";
        payouts=@"yes";
        voidinvoices=@"yes";
        hold=@"yes";
        endcash=@"yes";
        
    }

}
-(void)infoButton1Clicked:(UIButton *)sender
{
    
    if ([administrative isEqualToString:@"no"]){
    inventory=@"no";
    reports=@"no";
    settings=@"no";
    allowexit=@"no";
    deleteitems=@"no";
    endTransactions=@"no";
    forceCreditcard=@"no";
    
    customers=@"no";
    invoicediscounts=@"no";
    pricechnages=@"no";
    payouts=@"no";
    voidinvoices=@"no";
    hold=@"no";
    endcash=@"no";
    
   }else  if ([administrative isEqualToString:@"yes"]){
    inventory=@"yes";
    reports=@"yes";
    settings=@"yes";
    allowexit=@"yes";
    deleteitems=@"yes";
    endTransactions=@"yes";
    forceCreditcard=@"yes";
    
    customers=@"yes";
    invoicediscounts=@"yes";
    pricechnages=@"yes";
    payouts=@"yes";
    voidinvoices=@"yes";
    hold=@"yes";
    endcash=@"yes";
    
    }

    NSInteger selectedBtn=sender.tag;
    NSString *num=EmployeeIdField.text;
    if ([num length]<=0){
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Please Enter Employee ID" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }
    else{

    if (selectedBtn==100){
        if (!PermissionsPopupView)
        PermissionsPopupView=[[UIView alloc]init];
        if (isLandScope) {
            PermissionsPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            PermissionsPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PermissionsPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PermissionsPopupView];
        if (!PermissionsView)
        PermissionsView=[[UIScrollView alloc] init];
        if (isLandScope) {
            
             PermissionsView.frame=CGRectMake(25, 50, PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height-100);
        }else{
             PermissionsView.frame=CGRectMake(25, 100, PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height-300);
        }
       
       //PermissionsView.contentSize=CGSizeMake(PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height+200);
        [PermissionsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [PermissionsView.layer setBorderWidth:2.0];
        [PermissionsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PermissionsPopupView addSubview:PermissionsView];
        
        CGFloat permissionwidth=(PermissionsView.frame.size.width)/4;
        CGFloat perm=(permissionwidth/2);
        
        if (!PermissonsTextlbl)
        PermissonsTextlbl=[[UILabel alloc] init];
        PermissonsTextlbl.frame=CGRectMake(permissionwidth+100, 10,permissionwidth+100, 40);
        [PermissonsTextlbl setFont:[UIFont systemFontOfSize:28.0f]];
        [PermissonsTextlbl setBackgroundColor:[UIColor clearColor]];
        [PermissonsTextlbl setTextColor:[UIColor whiteColor]];
        [PermissonsTextlbl setText:@"Permissions"];
        [PermissonsTextlbl setTextAlignment:NSTextAlignmentLeft];
        [PermissionsView addSubview:PermissonsTextlbl];
        
        int s=100;
        NSArray *labelArray;
        for (int i=0; i<7; i++)
        {
            
            PermissionLbl=[[UILabel alloc] init];
            PermissionLbl.frame=CGRectMake(perm-60, s,permissionwidth+80, 40);
            
            PermissionLbl.tag=i+100;
            [PermissionLbl setFont:[UIFont systemFontOfSize:24.0f]];
            [PermissionLbl setBackgroundColor:[UIColor clearColor]];
            [PermissionLbl setTextColor:[UIColor whiteColor]];
            if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Inventory",@"Reports",@"Settings",@"Allow Exit",@"Delete Items",@"End Transactions",@"Force CreditCard",nil];
            [PermissionLbl setText:[labelArray objectAtIndex:i]];
            [PermissionLbl setTextAlignment:NSTextAlignmentLeft];
            [PermissionsView addSubview:PermissionLbl];
            
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            Myswitch=[[UISwitch alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            Myswitch.frame=CGRectMake(PermissionLbl.frame.size.width+10, s+5,permissionwidth, 40);
          
            Myswitch.tag=i+100;
            
            
            [Myswitch addTarget:self action:@selector(MyswitchClicked:) forControlEvents:UIControlEventValueChanged];
            if (Myswitch.tag==100)
            {
                if ([inventory isEqualToString:@"yes"])
                { [Myswitch setOn:TRUE animated:YES];
                    
                    inventory=@"yes";
                }
                else{
                   [Myswitch setOn:FALSE animated:YES];
                    inventory=@"no";
                    
                }
            }
            if (Myswitch.tag==101)
            {
                if ([reports isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    reports=@"yes";
                }
                else{
                   
                    
                     [Myswitch setOn:FALSE animated:YES];
                    reports=@"no";
                    
                }
            }
            if (Myswitch.tag==102)
            {
                if ([settings isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                   
                    settings=@"yes";
                }
                else{
                     [Myswitch setOn:FALSE animated:YES];
                    
                    settings=@"no";
                    
                }
            }
            if (Myswitch.tag==103)
            {
                if ([allowexit isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    allowexit=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    
                    allowexit=@"no";
                    
                }
            }
            if (Myswitch.tag==104)
            {
                if ([deleteitems isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                   
                    deleteitems=@"yes";
                }
                else{
                     [Myswitch setOn:FALSE animated:YES];
                    deleteitems=@"no";
                    
                }
            }
            if (Myswitch.tag==105)
            {
                if ([endTransactions isEqualToString:@"yes"])
                {
                     [Myswitch setOn:TRUE animated:YES];
                   
                    endTransactions=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    endTransactions=@"no";
                    
                }
            }
            if (Myswitch.tag==106)
            {
                if ([forceCreditcard isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    
                    forceCreditcard=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    forceCreditcard=@"no";
                    
                }
            }
        
            [PermissionsView addSubview:Myswitch];
            
            s=s+60;
            
        }
        int m=100;
        NSArray *labelArray2;
        for (int i=0; i<7; i++)
        {
            
            Permissionlbl2=[[UILabel alloc] init];
            Permissionlbl2.frame=CGRectMake(perm+PermissionLbl.frame.size.width, m,permissionwidth+80, 40);
            
            Permissionlbl2.tag=i+100;
            [Permissionlbl2 setFont:[UIFont systemFontOfSize:24.0f]];
            [Permissionlbl2 setBackgroundColor:[UIColor clearColor]];
            [Permissionlbl2 setTextColor:[UIColor whiteColor]];
            if (!labelArray2)
            labelArray2=[[NSArray alloc] initWithObjects:@"Customers",@"Invoice Discounts",@"Invoice Price Changes",@"Vendor Payouts",@"Void Invoices",@"Hold&Print",@"End Cash Transactions",nil];
            [Permissionlbl2 setText:[labelArray objectAtIndex:i]];
            [Permissionlbl2 setTextAlignment:NSTextAlignmentLeft];
            [PermissionsView addSubview:Permissionlbl2];
            
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            SecondSwitch=[[UISwitch alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            SecondSwitch.frame=CGRectMake(perm+PermissionLbl.frame.size.width-30+Permissionlbl2.frame.size.width+40, m+5,permissionwidth, 40);
            
            SecondSwitch.tag=i+100;
            [SecondSwitch addTarget:self action:@selector(SecondswitchClicked:) forControlEvents:UIControlEventValueChanged];
            if (SecondSwitch.tag==100)
            {
                if ([customers isEqualToString:@"yes"])
                {
                      [SecondSwitch setOn:TRUE animated:YES];
                    customers=@"yes";
                }
                
                else
                {
                   [SecondSwitch setOn:FALSE animated:YES];
                    customers=@"no";
                    
                }
            }
            if (SecondSwitch.tag==101)
            {
                if ([invoicediscounts isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    invoicediscounts=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    invoicediscounts=@"no";
                    
                }
            }
            if (SecondSwitch.tag==102)
            {
                if ([pricechnages isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    pricechnages=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    pricechnages=@"no";
                    
                }
            }
            if (SecondSwitch.tag==103)
            {
                if ([payouts isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    payouts=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    payouts=@"no";
                    
                }
            }
            if (SecondSwitch.tag==104)
            {
                if ([voidinvoices isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    voidinvoices=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    voidinvoices=@"no";
                    
                }
            }
            if (SecondSwitch.tag==105)
            {
                if ([hold isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    hold=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    hold=@"no";
                    
                }
            }
            if (SecondSwitch.tag==106)
            {
                if ([endcash isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    endcash=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    endcash=@"no";
                    
                }
            }
            
            [PermissionsView addSubview:SecondSwitch];
            
            m=m+60;
            
        }
        @autoreleasepool {
            SavePermissionBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavePermissionBtn.frame=CGRectMake(permissionwidth+100, 580, 80, 30);
            [SavePermissionBtn addTarget:self action:@selector(SavePermissions) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavePermissionBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavePermissionBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [PermissionsView addSubview:SavePermissionBtn];
            
            CancelPermissionsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelPermissionsBtn.frame=CGRectMake(permissionwidth+220, 580, 80, 30);
            [CancelPermissionsBtn addTarget:self action:@selector(CancelPermissions) forControlEvents:UIControlEventTouchUpInside];
            [CancelPermissionsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelPermissionsBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [PermissionsView addSubview:CancelPermissionsBtn];
        }
      
        
    }else if (selectedBtn==102){
        if (!PayrollPopUpView)
        PayrollPopUpView=[[UIView alloc]init];
        if (isLandScope) {
            PayrollPopUpView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            PayrollPopUpView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PayrollPopUpView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PayrollPopUpView];
        if (!PayrollView)
        PayrollView=[[UIScrollView alloc] init];
        if (isLandScope){
             PayrollView.frame=CGRectMake(25, 50, PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height-100);
        }else{
             PayrollView.frame=CGRectMake(25, 100, PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height-300);
        }
       
        PayrollView.contentSize=CGSizeMake(PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height+200);
        [PayrollView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [PayrollView.layer setBorderWidth:2.0];
        [PayrollView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PayrollPopUpView addSubview:PayrollView];
        
        CGFloat payrollwidth=(PayrollView.frame.size.width)/2;
        CGFloat pay=(payrollwidth/2);
        if (!PayrollTextLbl)
        PayrollTextLbl=[[UILabel alloc] init];
        PayrollTextLbl.frame=CGRectMake(payrollwidth-80, 10,payrollwidth+100, 40);
        [PayrollTextLbl setFont:[UIFont systemFontOfSize:25.0f]];
        [PayrollTextLbl setBackgroundColor:[UIColor clearColor]];
        [PayrollTextLbl setTextColor:[UIColor whiteColor]];
        [PayrollTextLbl setText:@"Payroll Details"];
        [PayrollTextLbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:PayrollTextLbl];
         if (!Excludelbl)
        Excludelbl=[[UILabel alloc] init];
        Excludelbl.frame=CGRectMake(pay-160, 60,payrollwidth+80, 40);
        [Excludelbl setFont:[UIFont systemFontOfSize:22.0f]];
        [Excludelbl setBackgroundColor:[UIColor clearColor]];
        [Excludelbl setTextColor:[UIColor whiteColor]];
        [Excludelbl setText:@"Exclude From Payroll"];
        Excludelbl.lineBreakMode = NSLineBreakByWordWrapping;
        Excludelbl.numberOfLines = 2;
        [Excludelbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:Excludelbl];
        if (!ExcludeBtn)
        ExcludeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ExcludeBtn.frame=CGRectMake(Excludelbl.frame.size.width-150, 65,30, 30);
        [ExcludeBtn addTarget:self action:@selector(ExcludeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        if ([Exclude isEqualToString:@"yes"])
        {
            ExcludeBtn.selected=YES;
            Exclude=@"yes";
        }else{
            ExcludeBtn.selected=NO;
            Exclude=@"no";
            
        }
        [ExcludeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [ExcludeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
        [ExcludeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
        [PayrollView addSubview:ExcludeBtn];
        
        
        int k=100;
        NSArray *labelArray;
        for (int i=0; i<5; i++)
        {
            
            PayrollLbl=[[UILabel alloc] init];
            PayrollLbl.frame=CGRectMake(pay-175, k,payrollwidth+80, 40);
            
            PayrollLbl.tag=i+100;
            [PayrollLbl setFont:[UIFont systemFontOfSize:24.0f]];
            [PayrollLbl setBackgroundColor:[UIColor clearColor]];
            [PayrollLbl setTextColor:[UIColor whiteColor]];
            if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Federal Allowances",@"Additional Federal Withholding Amount",@"Sate Allowances",@"Additional State Withholding Amount",@"Sate Additional Credits",nil];
            [PayrollLbl setText:[labelArray objectAtIndex:i]];
            [PayrollLbl setTextAlignment:NSTextAlignmentLeft];
            [PayrollView addSubview:PayrollLbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            PayrollField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            PayrollField.frame=CGRectMake(PayrollLbl.frame.size.width-10, k,payrollwidth-80, 40);
            PayrollField.delegate=self;
            PayrollField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            PayrollField.leftView = paddingview;
            PayrollField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            PayrollField.leftViewMode = UITextFieldViewModeAlways;
            [PayrollField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (PayrollField.tag==100)
            {
                PayrollField.text=federal;
            }
            if (PayrollField.tag==101)
            {
                PayrollField.text=federalAmount;
            }
            if (PayrollField.tag==102)
            {
                PayrollField.text=stateallowances;
            }
            if (PayrollField.tag==103)
            {
                PayrollField.text=stateAmount;
            }
            if (PayrollField.tag==104)
            {
                PayrollField.text=credits;
            }
            
            [PayrollField addTarget:self action:@selector(PayrollinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [PayrollField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [PayrollView addSubview:PayrollField];
            
            k=k+60;
            paddingview=nil;
            
        }
        // //NSLog(@"%d",k);
        
        if (!Exemptlbl)
        Exemptlbl=[[UILabel alloc] init];
        Exemptlbl.frame=CGRectMake(pay-175, 400,payrollwidth+80, 40);
        [Exemptlbl setFont:[UIFont systemFontOfSize:22.0f]];
        [Exemptlbl setBackgroundColor:[UIColor clearColor]];
        [Exemptlbl setTextColor:[UIColor whiteColor]];
        [Exemptlbl setText:@"Exempt"];
        Exemptlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Exemptlbl.numberOfLines = 2;
        [Exemptlbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:Exemptlbl];
         if (!ExemptBtn)
        ExemptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        ExemptBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 400,payrollwidth-80, 40);
        [ExemptBtn addTarget:self action:@selector(ExemptBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [ExemptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [ExemptBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        //[DepartmentBtn setTitle:cardType forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PayrollView addSubview:ExemptBtn];
        if (!ExemptsTable)
        ExemptsTable = [[UITableView alloc] initWithFrame:CGRectMake(Exemptlbl.frame.size.width-5, 440,payrollwidth-80, 100) style:UITableViewStylePlain];
        ExemptsTable.backgroundColor=[UIColor whiteColor];
        ExemptsTable.delegate = self;
        ExemptsTable.dataSource = self;
        ExemptsTable.scrollEnabled = YES;
        ExemptsTable.hidden=YES;
        [ExemptsTable.layer setBorderWidth: 1.0];
        [ExemptsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [PayrollView addSubview:ExemptsTable];
        if (!FillingStatuslbl)
        FillingStatuslbl=[[UILabel alloc] init];
        FillingStatuslbl.frame=CGRectMake(pay-175, 460,payrollwidth+80, 40);
        [FillingStatuslbl setFont:[UIFont systemFontOfSize:22.0f]];
        [FillingStatuslbl setBackgroundColor:[UIColor clearColor]];
        [FillingStatuslbl setTextColor:[UIColor whiteColor]];
        [FillingStatuslbl setText:@"Filling Status"];
        FillingStatuslbl.lineBreakMode = NSLineBreakByWordWrapping;
        FillingStatuslbl.numberOfLines = 2;
        [FillingStatuslbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:FillingStatuslbl];
         if (!FillingBtn)
        FillingBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        FillingBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 460,payrollwidth-80, 40);
        [FillingBtn addTarget:self action:@selector(FillingBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [FillingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [FillingBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        //[DepartmentBtn setTitle:cardType forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PayrollView addSubview:FillingBtn];
         if (!FillingsTable)
        FillingsTable = [[UITableView alloc] initWithFrame:CGRectMake(Exemptlbl.frame.size.width-5, 500,payrollwidth-80, 100) style:UITableViewStylePlain];
        FillingsTable.backgroundColor=[UIColor whiteColor];
        FillingsTable.delegate = self;
        FillingsTable.dataSource = self;
        FillingsTable.scrollEnabled = YES;
        FillingsTable.hidden=YES;
        [FillingsTable.layer setBorderWidth: 1.0];
        [FillingsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [PayrollView addSubview:FillingsTable];
        
        @autoreleasepool {
            SavePayrollBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavePayrollBtn.frame=CGRectMake(payrollwidth-100, 620, 80, 30);
            [SavePayrollBtn addTarget:self action:@selector(SavepayrollInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavePayrollBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavePayrollBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [PayrollView addSubview:SavePayrollBtn];
            
            CancelPayrollBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelPayrollBtn.frame=CGRectMake(payrollwidth+20, 620, 80, 30);
            [CancelPayrollBtn addTarget:self action:@selector(CancelpayrollInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelPayrollBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelPayrollBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [PayrollView addSubview:CancelPayrollBtn];
        }
    }else if (selectedBtn==101){
        PersonalInfoPopupView=[[UIView alloc]init];
        if (isLandScope) {
            PersonalInfoPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            PersonalInfoPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PersonalInfoPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PersonalInfoPopupView];
        
        PersonalInfoView=[[UIScrollView alloc] init];
        if (isLandScope) {
            
             PersonalInfoView.frame=CGRectMake(75, 50, PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height-100);
        }
        else
        {
          PersonalInfoView.frame=CGRectMake(75, 100, PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height-200);
       
        }
        PersonalInfoView.contentSize=CGSizeMake(PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height+200);
        
        [PersonalInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [PersonalInfoView.layer setBorderWidth:2.0];
        [PersonalInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PersonalInfoPopupView addSubview:PersonalInfoView];
        
        CGFloat fieldwidth=(PersonalInfoView.frame.size.width)/2;
        
        CGFloat o=(fieldwidth/2);
        PersonalInfotextlbl=[[UILabel alloc] init];
        PersonalInfotextlbl.frame=CGRectMake(fieldwidth-110, 10,fieldwidth+100, 40);
        
        [PersonalInfotextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [PersonalInfotextlbl setBackgroundColor:[UIColor clearColor]];
        [PersonalInfotextlbl setTextColor:[UIColor whiteColor]];
        
        [PersonalInfotextlbl setText:@"Personal Info Details"];
        [PersonalInfotextlbl setTextAlignment:NSTextAlignmentLeft];
        [PersonalInfoView addSubview:PersonalInfotextlbl];
        
        int d=70;
        
        for (int i=0; i<10; i++)
        {
            
            PersonalInfolbl=[[UILabel alloc] init];
            PersonalInfolbl.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            
            PersonalInfolbl.tag=i+100;
            [PersonalInfolbl setFont:[UIFont systemFontOfSize:24.0f]];
            [PersonalInfolbl setBackgroundColor:[UIColor clearColor]];
            [PersonalInfolbl setTextColor:[UIColor whiteColor]];
            NSArray *labelArray=[[NSArray alloc] initWithObjects:@"Name*",@"SSN/ID* ",@"Store Email",@"Phone Number",@"Birthday",@"Address",@"City",@"Country",@"State",@"Zip/Postal Code",nil];
            [PersonalInfolbl setText:[labelArray objectAtIndex:i]];
            [PersonalInfolbl setTextAlignment:NSTextAlignmentLeft];
            [PersonalInfoView addSubview:PersonalInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            PersonalInfoField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            PersonalInfoField.frame=CGRectMake(PersonalInfolbl.frame.size.width-20, d,fieldwidth-80, 40);
            PersonalInfoField.delegate=self;
            PersonalInfoField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            PersonalInfoField.leftView = paddingview;
            PersonalInfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            PersonalInfoField.leftViewMode = UITextFieldViewModeAlways;
            [PersonalInfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
           
            if (PersonalInfoField.tag==100)
            {
                PersonalInfoField.text=Name;
            }
            if (PersonalInfoField.tag==101)
            {
                PersonalInfoField.text=ID;
            }
            if (PersonalInfoField.tag==102)
            {
                PersonalInfoField.text=Email;
            }
            if (PersonalInfoField.tag==103)
            {
                PersonalInfoField.text=Phonenumber;
            }
            if (PersonalInfoField.tag==104)
            {
                PersonalInfoField.text=Birthday;
            }
            if (PersonalInfoField.tag==105)
            {
                PersonalInfoField.text=Address;
            }
            if (PersonalInfoField.tag==106)
            {
                PersonalInfoField.text=City;
            }
            if (PersonalInfoField.tag==107)
            {
                PersonalInfoField.text=City;
            }
            if (PersonalInfoField.tag==108)
            {
                PersonalInfoField.text=Country;
            }
            if (PersonalInfoField.tag==109)
            {
                PersonalInfoField.text=Zipcode;
            }
           
            [PersonalInfoField addTarget:self action:@selector(personalinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [PersonalInfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [PersonalInfoView addSubview:PersonalInfoField];
            
            d=d+60;
            
        }

        @autoreleasepool {
            SavePersonalInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            SavePersonalInfoBtn.frame=CGRectMake(fieldwidth-100, 720, 80, 30);
            [SavePersonalInfoBtn addTarget:self action:@selector(SavePersonalInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavePersonalInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavePersonalInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [PersonalInfoView addSubview:SavePersonalInfoBtn];
            
            CancelPersonalInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelPersonalInfoBtn.frame=CGRectMake(fieldwidth+20, 720, 80, 30);
            [CancelPersonalInfoBtn addTarget:self action:@selector(CancelpersonalInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelPersonalInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelPersonalInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [PersonalInfoView addSubview:CancelPersonalInfoBtn];
        }
       
    }else if (selectedBtn==103){
            if (!StoresPopupView)
            StoresPopupView=[[UIView alloc]init];
            if (isLandScope) {
                StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
            }else{
                
                StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
            }
            [StoresPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
            [self.view addSubview:StoresPopupView];
            if (!StoresView)
            StoresView=[[UIView alloc] init];
            if (isLandScope){
                StoresView.frame=CGRectMake(100, 50, StoresPopupView.frame.size.width-200, StoresPopupView.frame.size.height-150);
            }else{
                StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
            }
            [StoresView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
            [StoresView.layer setBorderWidth:2.0];
            [StoresView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
            [StoresPopupView addSubview:StoresView];
        
            StoreDataArray=[[NSMutableArray alloc]init];
            StoreIdsArray=[[NSMutableArray alloc]init];
         NSString *querySQL5 = [NSString stringWithFormat: @"SELECT store_id,store_name FROM store_details"];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:storesArray];
        
            for (NSDictionary *myDict in storesArray)
            {
                [StoreDataArray addObject:[myDict objectForKey:@"store_id"]];
                
                [StoreIdsArray addObject:[myDict objectForKey:@"store_name"]];
            }
            
            CGFloat widthfield4=(StoresView.frame.size.width)/4;
            if (!StoresTextlbl)
            StoresTextlbl=[[UILabel alloc] init];
            StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
            [StoresTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
            [StoresTextlbl setBackgroundColor:[UIColor clearColor]];
            [StoresTextlbl setTextColor:[UIColor whiteColor]];
            [StoresTextlbl setText:@"Store Details"];
            [StoresTextlbl setTextAlignment:NSTextAlignmentLeft];
            [StoresView addSubview:StoresTextlbl];
            
            if (!Storeslbl)
            Storeslbl=[[UILabel alloc] init];
            Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
            [Storeslbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Storeslbl setBackgroundColor:[UIColor clearColor]];
            [Storeslbl setTextColor:[UIColor whiteColor]];
            [Storeslbl setText:@"Add Store"];
            Storeslbl.lineBreakMode = NSLineBreakByWordWrapping;
            Storeslbl.numberOfLines = 2;
            [Storeslbl setTextAlignment:NSTextAlignmentLeft];
            [StoresView addSubview:Storeslbl];
            if (!StoresBtn)
            StoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
            [StoresBtn addTarget:self action:@selector(AddstoreClicked) forControlEvents:UIControlEventTouchUpInside];
            [StoresBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [StoresBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [StoresView addSubview:StoresBtn];
            
            if (!StoresListTable)
            StoresListTable = [[UITableView alloc] initWithFrame:CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100) style:UITableViewStylePlain];
            StoresListTable.backgroundColor=[UIColor whiteColor];
            StoresListTable.delegate = self;
            StoresListTable.dataSource = self;
            StoresListTable.scrollEnabled = YES;
            StoresListTable.hidden=YES;
            [StoresListTable.layer setBorderWidth: 1.0];
            [StoresListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [StoresView addSubview:StoresListTable];
            if (!StoresDataTable)
            StoresDataTable = [[UITableView alloc] initWithFrame:CGRectMake(50, 200,StoresView.frame.size.width-100, 300) style:UITableViewStylePlain];
            StoresDataTable.backgroundColor=[UIColor whiteColor];
            StoresDataTable.delegate = self;
            StoresDataTable.dataSource = self;
            StoresDataTable.scrollEnabled = YES;
            [StoresDataTable.layer setBorderWidth: 1.0];
            [StoresDataTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [StoresView addSubview:StoresDataTable];
        @autoreleasepool {
            SavestoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
            [SavestoresBtn addTarget:self action:@selector(SaveStoreInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavestoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavestoresBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [StoresView addSubview:SavestoresBtn];
            
            CancelStoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
            [CancelStoresBtn addTarget:self action:@selector(CancelStoreInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelStoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelStoresBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [StoresView addSubview:CancelStoresBtn];
        }
        
        }
    }
}
-(void)AddstoreClicked
{
    if (StoresListTable.hidden==1)
    {
        
        StoresListTable.hidden=NO;
        
        
    }
    else if (StoresListTable.hidden==0)
    {
        [StoresListTable setHidden:YES];
        
    }
}
-(void)CancelStoreInfo
{
    NSArray *StoresViewArray = StoresView.subviews;
    for (int i = 0; i<[StoresViewArray count]; i++) {
        UIView *vi =[StoresViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *StoresPopupViewArray = StoresPopupView.subviews;
    for (int i = 0; i<[StoresPopupViewArray count]; i++) {
        UIView *vi =[StoresPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [StoresView removeFromSuperview],[StoresPopupView removeFromSuperview];
    [StoreDataArray removeAllObjects];
    [StoreIdsArray  removeAllObjects];
}
-(void)SaveStoreInfoData
{
    NSArray *StoresViewArray = StoresView.subviews;
    for (int i = 0; i<[StoresViewArray count]; i++) {
        UIView *vi =[StoresViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *StoresPopupViewArray = StoresPopupView.subviews;
    for (int i = 0; i<[StoresPopupViewArray count]; i++) {
        UIView *vi =[StoresPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [StoresView removeFromSuperview],[StoresPopupView removeFromSuperview];
    [StoreDataArray removeAllObjects];
    [StoreIdsArray  removeAllObjects];
     //[StoresPopupView removeFromSuperview];
}

-(void)MyswitchClicked:(UISwitch *)sender
{
    NSInteger selected=sender.tag;
    if (selected==100)
    {
        if (sender.on )
        {
            
            [sender setOn:FALSE animated:YES];
            inventory=@"no";
        }
        else
        {
           
            [sender setOn:TRUE animated:YES];
            inventory=@"yes";
        }
    }
    if (selected==101)
    {
        if ( sender.on )
        {
           [sender setOn:FALSE animated:YES];
            reports=@"no";
            
        }
        else
        {
            reports=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==102)
    {
        if ( sender.on )
        {
            settings=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        { settings=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==103)
    {
        if ( sender.on )
        {    allowexit=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
             allowexit=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==104)
    {
        if ( sender.on )
        {
            deleteitems=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
            deleteitems=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==105)
    {
        if ( sender.on )
        {
             endTransactions=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
            endTransactions=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==106)
    {
        if ( sender.on )
        {
            forceCreditcard=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
            forceCreditcard=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
}
-(void)SecondswitchClicked:(UISwitch *)sender
{
    NSInteger selected=sender.tag;
    if (selected==100)
    {
        if ( sender.on )
        {
          customers=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
             customers=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==101)
    {
        if ( sender.on )
        {
            invoicediscounts=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
           invoicediscounts=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==102)
    {
        if ( sender.on )
        {
           pricechnages=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
           pricechnages=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==103)
    {
        if (sender.on )
        {
           payouts=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
           payouts=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==104)
    {
        if (sender.on )
        {
           voidinvoices=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
            voidinvoices=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==105)
    {
        if ( sender.on )
        {
            hold=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
            hold=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
    if (selected==106)
    {
        if ( sender.on )
        {
           endcash=@"no";
            [sender setOn:FALSE animated:YES];
        }
        else
        {
            endcash=@"yes";
            [sender setOn:TRUE animated:YES];
        }
    }
}
-(void)SavepayrollInfoData
{
    NSArray *PayrollViewArray = PayrollView.subviews;
    for (int i = 0; i<[PayrollViewArray count]; i++) {
        UIView *vi =[PayrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PayrollPopUpViewArray = PayrollPopUpView.subviews;
    for (int i = 0; i<[PayrollPopUpViewArray count]; i++) {
        UIView *vi =[PayrollPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PayrollView removeFromSuperview],[PayrollPopUpView removeFromSuperview];
   // PayrollView=nil,PayrollPopUpView=nil;
}
-(void)CancelpayrollInfo
{
    NSArray *PayrollViewArray = PayrollView.subviews;
    for (int i = 0; i<[PayrollViewArray count]; i++) {
        UIView *vi =[PayrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PayrollPopUpViewArray = PayrollPopUpView.subviews;
    for (int i = 0; i<[PayrollPopUpViewArray count]; i++) {
        UIView *vi =[PayrollPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PayrollView removeFromSuperview],[PayrollPopUpView removeFromSuperview];
    // PayrollView=nil,PayrollPopUpView=nil;
}
-(void)SavePermissions
{
    NSArray *PermissionsViewArray = PermissionsView.subviews;
    for (int i = 0; i<[PermissionsViewArray count]; i++) {
        UIView *vi =[PermissionsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PermissionsPopupViewArray = PermissionsPopupView.subviews;
    for (int i = 0; i<[PermissionsPopupViewArray count]; i++) {
        UIView *vi =[PermissionsPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PermissionsView removeFromSuperview],[PermissionsPopupView removeFromSuperview];
    //PermissionsView=nil,PermissionsPopupView=nil;

}
-(void)CancelPermissions
{
    NSArray *PermissionsViewArray = PermissionsView.subviews;
    for (int i = 0; i<[PermissionsViewArray count]; i++) {
        UIView *vi =[PermissionsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *PermissionsPopupViewArray = PermissionsPopupView.subviews;
    for (int i = 0; i<[PermissionsPopupViewArray count]; i++) {
        UIView *vi =[PermissionsPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PermissionsView removeFromSuperview],[PermissionsPopupView removeFromSuperview];
    
   // PermissionsView=nil,PermissionsPopupView=nil;
}
-(void)ExemptBtnClicked
{
    if (ExemptsTable.hidden==1)
    {
        FillingBtn.hidden=YES;
       
        ExemptsTable.hidden=NO;
        
        
    }
    else if (ExemptsTable.hidden==0)
    {
       
        FillingBtn.hidden=NO;
        [ExemptsTable setHidden:YES];
        
    }
}
-(void)FillingBtnClicked
{
    if (FillingsTable.hidden==1)
    {
        
        FillingsTable.hidden=NO;
        
        
    }
    else if (FillingsTable.hidden==0)
    {
    
        [FillingsTable setHidden:YES];
        
    }
}
-(void)personalinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        Name=sender.text;
    }
    if (selected == 101)
    {
        ID=sender.text;
    }
    if (selected == 102)
    {
        Email=sender.text;
    }
    if (selected == 103)
    {
        
        Phonenumber=sender.text;
    }
    if (selected == 104)
    {
        
        Birthday=sender.text;
    }
    if (selected == 105)
    {
        Address=sender.text;
    }
    if (selected == 106)
    {
        City=sender.text;
    }
    if (selected == 107)
    {
        
        Country=sender.text;
    }
    if (selected == 108)
    {
        
        state=sender.text;
    }
    if (selected == 109)
    {
        
        Zipcode=sender.text;
    }
}
-(void)PayrollinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        federal=sender.text;
    }
    if (selected == 101)
    {
        federalAmount=sender.text;
    }
    if (selected == 102)
    {
        stateallowances=sender.text;
    }
    if (selected == 103)
    {
        
        stateAmount=sender.text;
    }
    if (selected == 104)
    {
        
        credits=sender.text;
    }
}
-(void)SavePersonalInfoData
{
    NSArray *PersonalInfoViewArray = PersonalInfoView.subviews;
    for (int i = 0; i<[PersonalInfoViewArray count]; i++) {
        UIView *vi =[PersonalInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PersonalInfoPopupViewArray = PersonalInfoPopupView.subviews;
    for (int i = 0; i<[PersonalInfoPopupViewArray count]; i++) {
        UIView *vi =[PersonalInfoPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PersonalInfoView removeFromSuperview],[PersonalInfoPopupView removeFromSuperview];
}
-(void)CancelpersonalInfo
{
    NSArray *PersonalInfoViewArray = PersonalInfoView.subviews;
    for (int i = 0; i<[PersonalInfoViewArray count]; i++) {
        UIView *vi =[PersonalInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PersonalInfoPopupViewArray = PersonalInfoPopupView.subviews;
    for (int i = 0; i<[PersonalInfoPopupViewArray count]; i++) {
        UIView *vi =[PersonalInfoPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PersonalInfoView removeFromSuperview],[PersonalInfoPopupView removeFromSuperview];
    
   // [PersonalInfoPopupView removeFromSuperview];
}
-(void)SaveEmployeeData
{
    NSString *dept=[NSString stringWithFormat:@"%@",DepartmentBtn.titleLabel.text];
    Exempt=[NSString stringWithFormat:@"%@",ExemptBtn.titleLabel.text];
      Filling=[NSString stringWithFormat:@"%@",FillingBtn.titleLabel.text];
    if (!EmployeeIdsArray)
    EmployeeIdsArray=[[NSMutableArray alloc]init];
    NSString *password=nil;
  password=[[NSString alloc]init];
    password=[password encodeString:PasswordField.text] ;
    NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_employee_id FROM employee_table"];
    NSMutableArray *empArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:empArray];
    
    @autoreleasepool {
        for (NSDictionary *myDict in empArray)
        {
            NSString *catname=[myDict objectForKey:@"employee_employee_id"];
            
            [EmployeeIdsArray addObject:catname];
            
        }
    }
   
    NSUInteger objIdx = [EmployeeIdsArray containsObject:EmployeeIdField.text];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
    NSString *EinsertSql;
    EinsertSql=@"insert into employee_table (employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *empinsertArray=[[NSMutableArray alloc] initWithObjects:dept,EmployeeIdField.text,password,DisplaynameField.text,CardSwipeIdField.text,CustomerField.text,HoulrywageField.text,Disable,Cctips,administrative,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],password, nil];
        
        //NSLog(@"emp data %@ %@ password",DisplaynameField.text,password);
           //NSLog(@"emp data %@ %@",EinsertSql,empinsertArray);
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:EinsertSql withArguments:empinsertArray];
     
      NSString *PermissionsinsertSql,*PayrollSql,*Personalsql,*StoreSql;
    
     PermissionsinsertSql=@"insert into employee_permissions (emp_inventory,emp_customers,emp_reports,emp_discounts,emp_settings,emp_price_hanges,emp_allow_exit,emp_vendor_payouts,emp_delete_items,emp_void_invoices,emp_transactions,emp_holdprint,emp_creditcards,emp_endcash,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *emppersArray=[[NSMutableArray alloc]initWithObjects:inventory,customers,reports,invoicediscounts,settings,pricechnages,allowexit,payouts,deleteitems,voidinvoices,endTransactions,hold,forceCreditcard,endcash,EmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:PermissionsinsertSql withArguments:emppersArray];
    
      Personalsql=@"insert into employee_personal (emp_name,emp_id,emp_email,emp_phone,emp_birth,emp_address,emp_city,emp_country,emp_state,emp_postal,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *emppersonalArray=[[NSMutableArray alloc]initWithObjects:Name,ID,Email,Phonenumber,Birthday,Address,City,Country,state,Zipcode,EmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:Personalsql withArguments:emppersonalArray];
    
    
    PayrollSql=@"insert into employee_payroll (federal,amount,statea,stateAmount,credits,filingstatus,exempt,excludeCheck,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values (?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *emppayrollsArray=[[NSMutableArray alloc]initWithObjects:federal,federalAmount,stateallowances,stateAmount,credits,Filling,Exempt,Exclude,EmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:PayrollSql withArguments:emppayrollsArray];
  
        
        if ([SelectedStoredataArray count]>0)
        {
            for (int i=0; i<[SelectedStoredataArray count]; i++)
            {
                NSString *storename=[SelectedStoredataArray objectAtIndex:i];
                NSString *storeId=[SeleCtedStoreIdsArray objectAtIndex:i];
                
                StoreSql=@"insert into employee_store (emp_store_name,emp_store_id,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values (?,?,?,?,?,?)";
                NSMutableArray *storesArray=[[NSMutableArray alloc]initWithObjects:storename,storeId,EmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
                 // //NSLog(@"store data %@",StoreSql);
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:StoreSql withArguments:storesArray];
               
            
            }
        }
        
        
      
    
//Employee Data
         NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password,server_local FROM employee_table WHERE employee_employee_id='%@'",EmployeeIdField.text];
        
        NSMutableArray *employeesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:employeesArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values (?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"employee_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            EConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [EConnection start];
            }
        }

//Permissions Data
        
         NSString *querySQL2 = [NSString stringWithFormat: @"SELECT emp_inventory,emp_customers,emp_reports,emp_discounts,emp_settings,emp_price_hanges,emp_allow_exit,emp_vendor_payouts,emp_delete_items,emp_void_invoices,emp_transactions,emp_holdprint,emp_creditcards,emp_endcash,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_permissions WHERE employee_employee_id='%@'",EmployeeIdField.text];
        NSMutableArray *permissionsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:permissionsArray];
        
        NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
        [CategoryDict2 setObject:permissionsArray forKey:@"fields"];
        NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
        
        
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str2,@"employee_permissions",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_permissions&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
           
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            PermissionsConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [PermissionsConnection start];
            }
        }
//Personal Data
       
          NSString *personalquerySQL = [NSString stringWithFormat: @"SELECT emp_name,emp_id,emp_email,emp_phone,emp_birth,emp_address,emp_city,emp_country,emp_state,emp_postal,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_personal WHERE employee_employee_id='%@'",EmployeeIdField.text];
        NSMutableArray *personalsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:personalquerySQL resultsArray:personalsArray];
    
        NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
        [CategoryDict3 setObject:personalsArray forKey:@"fields"];
        NSDictionary *jsonDict3 = [NSDictionary dictionaryWithDictionary:CategoryDict3];
        
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
           
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values (?,?,?,?,?,?)";
            
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str3,@"employee_personal",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_personal&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            PersonalConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [PersonalConnection start];
            }
        }
//Payrolls Data
         NSString *payrollquerySQL = [NSString stringWithFormat:@"SELECT federal,amount,statea,stateAmount,credits,filingstatus,exempt,excludeCheck,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_payroll WHERE employee_employee_id='%@'",EmployeeIdField.text];
        NSMutableArray *payrollsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:payrollquerySQL resultsArray:payrollsArray];
        
        
        NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
        [CategoryDict4 setObject:payrollsArray forKey:@"fields"];
        NSDictionary *jsonDict4 = [NSDictionary dictionaryWithDictionary:CategoryDict4];
        
        
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str4,@"employee_payroll",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_payroll&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            PayrollConnections = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [PayrollConnections start];
            }
        }
//Store data
         NSString *storequerySQL = [NSString stringWithFormat:@"SELECT emp_store_name,emp_store_id,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_store WHERE employee_employee_id='%@'",EmployeeIdField.text];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:storequerySQL resultsArray:storesArray];
        
        NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
        [CategoryDict5 setObject:storesArray forKey:@"fields"];
        NSDictionary *jsonDict5 = [NSDictionary dictionaryWithDictionary:CategoryDict5];
        
        
        NSError *err5;
        
        NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
        
        NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"employee_store",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str5);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_store&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [StoreConnection start];
            }
        }
        NSString *empquerySQL = [NSString stringWithFormat:@"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password FROM employee_table"];
        
        NSMutableArray *employeeArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:empquerySQL resultsArray:employeeArray];
        
       
        NSMutableArray *rdarray=employeeArray;
        
        //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
        
        [employeepaginationObject   setCompleteresultset:rdarray];
        
        [employeepaginationObject    paginationinitializer:rdarray :20];
        
        [employeepaginationObject   paginationsegment].tintColor=[UIColor whiteColor];
        [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
        
        [[employeepaginationObject   paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [employeepaginationObject   paginationsegment].selectedSegmentIndex=selectedsegindex;
       [employeepaginationObject   activateResults:selectedsegindex];
        
        [EditEmployeeTable reloadData];
        
        
        EmployeeIdField.text=@"";
        CustomerField.text=@"";
        PasswordField.text=@"";
        DisplaynameField.text=@"";
        CardSwipeIdField.text=@"";
        HoulrywageField.text=@"";
    Name=@"";
    ID=@"";
    Email=@"";
    Phonenumber=@"";
    Birthday=@"";
    Address=@"";
    City=@"";
    Country=@"";
    state=@"";
    Zipcode=@"";
    
    inventory=@"";reports=@"";settings=@"";allowexit=@"";deleteitems=@"";endTransactions=@"";forceCreditcard=@"";
    customers=@"";invoicediscounts=@"";pricechnages=@"";payouts=@"";voidinvoices=@"";hold=@"";endcash=@"";
    Exclude=@"";federal=@"";federalAmount=@"";stateallowances=@"";stateAmount=@"";credits=@"";
    Exempt=@"";Filling=@"";
        Disable=@"";administrative=@"";Cctips=@"";
    
   
        
        SeleCtedStoreIdsArray=Nil;
        SelectedStoredataArray=nil;
       
        SelectedStoredataArray=[[NSMutableArray alloc]init];
           SeleCtedStoreIdsArray=[[NSMutableArray alloc]init];
        
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Employee Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }else{
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Employee ID already exist change the Employee ID" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
    }
    
}

- (void)longPress:(UILongPressGestureRecognizer*)gesture {
    if ( gesture.state == UIGestureRecognizerStateEnded ) {
        // //NSLog(@"Long Press");
    }
}
- (BOOL)shouldAutorotate
{
    // //NSLog(@"called");
    
    
    return YES;
    
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (tableView==EditEmployeeTable)
    {
        
            
            return 50;
    }
    else
    {
        return 50;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    // This will create a "invisible" footer
    return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
    
    // If you are not using ARC:
    // return [[UIView new] autorelease];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView==DepartmentListTable){
        return [DepartmentsArray count];
    }else if (tableView==EditDepartmentListTable){
        return [DepartmentsArray count];
    }else if (tableView== EditEmployeeTable){
        return [[employeepaginationObject   activeresultset] count]+1;
        
    }else if (tableView==StoresDataTable){
        return [SelectedStoredataArray count];
    }else if (tableView==StoresListTable){
        return [StoreDataArray count];
    }

    
    return YES;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (tableView == EditEmployeeTable){
        
        EmployeeCell  *cell = (EmployeeCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"EmployeeCell" owner:self options:nil];
            cell = employeeCell;
        }
        
        // // //NSLog(@"Dict :-%@",dict);
        if (indexPath.row==0){
            cell.employeeID_TextView.text = @"EmployeeID";
            cell.employeeName_TextView.text =@"EmployeeName";
            
            cell.employeeID_TextView.textColor=[UIColor blackColor];
            cell.employeeName_TextView.textColor=[UIColor blackColor];
           
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            cell.edit_Button.hidden=YES;
            cell.duplicate_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
            
        }else{
            
            cell.employeeID_TextView.text = [EmployeeIdsArray objectAtIndex:indexPath.row-1];
            cell.employeeName_TextView.text =[DisplayNamesArray objectAtIndex:indexPath.row-1];
          
            
            cell.employeeID_TextView.textColor=[UIColor whiteColor];
            cell.employeeName_TextView.textColor=[UIColor whiteColor];
            
            cell.edit_Button.hidden=NO;
            cell.duplicate_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            
            cell.edit_Button.tag=indexPath.row;
            cell.duplicate_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        
        return cell;
        
    }else{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        if(!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
        }
    
    if (tableView== DepartmentListTable)
    {
        cell.textLabel.text=[DepartmentsArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        
        
    }else if (tableView==EditDepartmentListTable){
        cell.textLabel.text=[DepartmentsArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
    }else if ([StoreDataArray  count]>0){
        if (tableView== StoresListTable)
        {
            cell.textLabel.text=[StoreDataArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            
            
        }
    }
    if ([SelectedStoredataArray  count]>0){
        if (tableView== StoresDataTable)
        {
            cell.textLabel.text=[SelectedStoredataArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            cell.textLabel.textColor=[UIColor blackColor];
            
            DeleteStoreBtn=[UIButton buttonWithType:UIButtonTypeCustom];
            [DeleteStoreBtn setFrame:CGRectMake(300, 10, 25, 25)];
            //[editBtn setTitle:@"edit" forState:UIControlStateNormal];
            
            [DeleteStoreBtn setImage:[UIImage imageNamed:@"deleteicon.png"] forState:UIControlStateNormal];
            
            
            [DeleteStoreBtn addTarget:self action:@selector(DeleteStoreData:) forControlEvents:UIControlEventTouchUpInside];
            DeleteStoreBtn.tag=indexPath.row;
            [cell.contentView addSubview:DeleteStoreBtn];
            
            
            
        }
    }
  
    return cell;
  }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (tableView==DepartmentListTable){
          PasswordField.hidden=NO;
        EmployeeIdField.hidden=NO;
        DepartmentListTable.hidden=YES;
        
        NSString *str=[DepartmentsArray objectAtIndex:indexPath.row];
        [DepartmentBtn setTitle:str forState:UIControlStateNormal];
    }else if (tableView==EditDepartmentListTable){
        EditPasswordField.hidden=NO;
        EditEmployeeIdField.hidden=NO;
        EditDepartmentListTable.hidden=YES;
         DuplicateEmployeeIdField.hidden=NO;
        NSString *str=[DepartmentsArray objectAtIndex:indexPath.row];
        [EditDepartmentBtn setTitle:str forState:UIControlStateNormal];
    }else if (tableView==StoresListTable){
        
        StoresListTable.hidden=YES;
        NSString *selectedstr=[StoreDataArray objectAtIndex:indexPath.row];
        
        NSString *selectedid=[StoreIdsArray objectAtIndex:indexPath.row];
        
        [StoresBtn setTitle:selectedstr forState:UIControlStateNormal];
        
        
        
        if ([SelectedStoredataArray count]>0)
        {
            NSUInteger objIdx = [SelectedStoredataArray containsObject:selectedstr];
            
            
           // // //NSLog(@"%lu",(unsigned long)objIdx);
            if(objIdx == 0 )
            {
                [SeleCtedStoreIdsArray addObject:selectedid];
                [SelectedStoredataArray addObject:selectedstr];
                [StoresDataTable reloadData];
                
            }
            else
            {
                
                
                UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Store already exist" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                [alert show];
            }
        }
        else
        {
             [SeleCtedStoreIdsArray addObject:selectedid];
            [SelectedStoredataArray addObject:selectedstr];
            [StoresDataTable reloadData];
        }
        
    }
    
    
}
-(void)DeleteStoreData:(UIButton *)sender
{
    NSInteger selected=sender.tag;
    [SeleCtedStoreIdsArray removeObjectAtIndex:selected];
    [SelectedStoredataArray removeObjectAtIndex:selected];
    [StoresDataTable reloadData];
}

- (IBAction)employee_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    if (!EditEmployeePopUp)
    EditEmployeePopUp=[[UIView alloc]init];
    if (isLandScope) {
        EditEmployeePopUp.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        EditEmployeePopUp.frame=CGRectMake(0, 0, 768, 1024);
    }
    [EditEmployeePopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:EditEmployeePopUp];
    
     if (!EditemployeeView)
    EditemployeeView=[[UIScrollView alloc]init];
    if (isLandScope) {
        EditemployeeView.frame=CGRectMake(20, 100, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-200);
    }else{
        EditemployeeView.frame=CGRectMake(20, 200, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-500);
    }
    EditemployeeView.contentSize=CGSizeMake(EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height+100);
    
    [EditemployeeView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [EditemployeeView.layer setBorderWidth:2.0];
    [EditemployeeView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [EditEmployeePopUp addSubview:EditemployeeView];
    
    
    NSString *Dept=[EmDepartmentsArray objectAtIndex:selectedrow];
    NSString *emID=[EmployeeIdsArray objectAtIndex:selectedrow];

    
    
    EmpPassword=[passwordsArray objectAtIndex:selectedrow];
    NSString *DisName=[DisplayNamesArray objectAtIndex:selectedrow];
    NSString *swipecard=[cardswipeidsArray objectAtIndex:selectedrow];
    NSString *custmer=[EmCustomersArray objectAtIndex:selectedrow];
    NSString *houly=[houlrywagesArray objectAtIndex:selectedrow];
    
    
    Disable=[disablesArray objectAtIndex:selectedrow];
    administrative=[administativesArray objectAtIndex:selectedrow];
    Cctips=[CctipsArray objectAtIndex:selectedrow];
    
    
    
    Name=[NamesArray objectAtIndex:selectedrow];
    ID=[IDsArray objectAtIndex:selectedrow];
    Email=[EmailsArray objectAtIndex:selectedrow];
    Phonenumber=[PhonenumbersArray objectAtIndex:selectedrow];
    Birthday=[BirthdaysArray objectAtIndex:selectedrow];
    Address=[AddresssArray objectAtIndex:selectedrow];
    City=[CitysArray objectAtIndex:selectedrow];
    Country=[CountrysArray objectAtIndex:selectedrow];
    state=[statesArray objectAtIndex:selectedrow];
    Zipcode=[ZipcodesArray objectAtIndex:selectedrow];
    
    Exclude=[ExcludesArray objectAtIndex:selectedrow];
    federal=[federalsArray objectAtIndex:selectedrow];
    federalAmount=[federalAmountsArray objectAtIndex:selectedrow];
    stateallowances=[stateallowancessArray objectAtIndex:selectedrow];
    stateAmount=[stateAmountsArray objectAtIndex:selectedrow];
    credits=[creditssArray objectAtIndex:selectedrow];
    Exempt=[DataExemptsArray objectAtIndex:selectedrow];
    Filling=[DataFillingsArray objectAtIndex:selectedrow];
    
    
    inventory=[inventorysArray objectAtIndex:selectedrow];
    reports=[reportssArray objectAtIndex:selectedrow];
    settings=[settingssArray objectAtIndex:selectedrow];
    allowexit=[allowexitsArray objectAtIndex:selectedrow];
    deleteitems=[deleteitemssArray objectAtIndex:selectedrow];
    endTransactions=[endTransactionssArray objectAtIndex:selectedrow];
    forceCreditcard=[forceCreditcardsArray objectAtIndex:selectedrow];
    customers=[customerssArray objectAtIndex:selectedrow];
    invoicediscounts=[invoicediscountssArray objectAtIndex:selectedrow];
    pricechnages=[pricechnagessArray objectAtIndex:selectedrow];
    
    payouts=[payoutssArray objectAtIndex:selectedrow];
    voidinvoices=[voidinvoicessArray objectAtIndex:selectedrow];
    hold=[holdsArray objectAtIndex:selectedrow];
    endcash=[endcashsArray objectAtIndex:selectedrow];
    
   // // //NSLog(@"Permissions %@,%@,%@,%@,%@,%@,%@,%@",inventory,customers,reports,invoicediscounts,settings,pricechnages,allowexit,payouts);
    
     NSString *querySQL = [NSString stringWithFormat:@"SELECT emp_store_name,emp_store_id FROM employee_store WHERE employee_employee_id='%@'",emID];
    NSMutableArray *empstoresArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:empstoresArray];
    
    SelectedStoredataArray=[[NSMutableArray alloc]init];
    SeleCtedStoreIdsArray=[[NSMutableArray alloc]init];
    
    DBstorenamesArray=[[NSMutableArray alloc]init];
    BdStoreidsArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for (NSDictionary *myDict in empstoresArray)
        {
            [DBstorenamesArray addObject:[myDict objectForKey:@"emp_store_name"]];
            
            [BdStoreidsArray addObject:[myDict objectForKey:@"emp_store_id"]];
        }
    }
   
    CGFloat Employee=(EditemployeeView.frame.size.width)/4;
    CGFloat E=(Employee/2)+20;
    if (!EditDepartmentlbl)
    EditDepartmentlbl=[[UILabel alloc] init];
    EditDepartmentlbl.frame=CGRectMake(E-90, 30,Employee, 50);
    [EditDepartmentlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditDepartmentlbl setBackgroundColor:[UIColor clearColor]];
    [EditDepartmentlbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentlbl setText:@"Department"];
    EditDepartmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditDepartmentlbl.numberOfLines = 2;
    [EditDepartmentlbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditDepartmentlbl];
     if (!EditDepartmentBtn)
    EditDepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditDepartmentBtn.frame=CGRectMake(Employee-5, 35,Employee, 40);
    [EditDepartmentBtn addTarget:self action:@selector(EditDepartmentBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditDepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditDepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditDepartmentBtn setTitle:Dept forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [EditemployeeView addSubview:EditDepartmentBtn];
    if (!EditDepartmentListTable)
    EditDepartmentListTable = [[UITableView alloc] initWithFrame:CGRectMake(Employee-5, 75,Employee, 100) style:UITableViewStylePlain];
    EditDepartmentListTable.backgroundColor=[UIColor whiteColor];
    EditDepartmentListTable.delegate = self;
    EditDepartmentListTable.dataSource = self;
    EditDepartmentListTable.scrollEnabled = YES;
    EditDepartmentListTable.hidden=YES;
    [EditDepartmentListTable.layer setBorderWidth: 1.0];
    [EditDepartmentListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditemployeeView addSubview:EditDepartmentListTable];
     if (!EditEmployeeIdLbl)
    EditEmployeeIdLbl=[[UILabel alloc] init];
    EditEmployeeIdLbl.frame=CGRectMake(E-90, 90,Employee, 50);
    [EditEmployeeIdLbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditEmployeeIdLbl setBackgroundColor:[UIColor clearColor]];
    [EditEmployeeIdLbl setTextColor:[UIColor whiteColor]];
    [EditEmployeeIdLbl setText:@"Employee ID"];
    EditEmployeeIdLbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditEmployeeIdLbl.numberOfLines = 2;
    [EditEmployeeIdLbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditEmployeeIdLbl];
      if (!EditEmployeeIdField)
    EditEmployeeIdField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditEmployeeIdField.frame=CGRectMake(Employee-5, 95,Employee, 40);
    EditEmployeeIdField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditEmployeeIdField.leftView = paddingview2;
    EditEmployeeIdField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditEmployeeIdField.leftViewMode = UITextFieldViewModeAlways;
    [EditEmployeeIdField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditEmployeeIdField.text=emID;
    [EditEmployeeIdField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditEmployeeIdField];
      if (!EditPasswordlbl)
    EditPasswordlbl=[[UILabel alloc] init];
    EditPasswordlbl.frame=CGRectMake(E-90, 150,Employee, 50);
    [EditPasswordlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditPasswordlbl setBackgroundColor:[UIColor clearColor]];
    [EditPasswordlbl setTextColor:[UIColor whiteColor]];
    [EditPasswordlbl setText:@"Password"];
    EditPasswordlbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditPasswordlbl.numberOfLines = 2;
    [EditPasswordlbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditPasswordlbl];
     if (!EditPasswordField)
    EditPasswordField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditPasswordField.frame=CGRectMake(Employee-5, 155,Employee, 40);
    EditPasswordField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditPasswordField.leftView = paddingview3;
    EditPasswordField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditPasswordField.leftViewMode = UITextFieldViewModeAlways;
    [EditPasswordField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditPasswordField.text=@"";
    [EditPasswordField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditPasswordField];
      if (!EditDisplaynamelbl)
    EditDisplaynamelbl=[[UILabel alloc] init];
    EditDisplaynamelbl.frame=CGRectMake(E-90, 210,Employee, 50);
    
    [EditDisplaynamelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditDisplaynamelbl setBackgroundColor:[UIColor clearColor]];
    [EditDisplaynamelbl setTextColor:[UIColor whiteColor]];
    [EditDisplaynamelbl setText:@"DisplayName"];
    EditDisplaynamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditDisplaynamelbl.numberOfLines = 2;
    [EditDisplaynamelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditDisplaynamelbl];
     if (!EditDisplaynameField)
    EditDisplaynameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditDisplaynameField.frame=CGRectMake(Employee-5, 215,Employee, 40);
    EditDisplaynameField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditDisplaynameField.leftView = paddingview4;
    EditDisplaynameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditDisplaynameField.leftViewMode = UITextFieldViewModeAlways;
    [EditDisplaynameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditDisplaynameField.text=DisName;
    [EditDisplaynameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditDisplaynameField];
    
     if (!EditCardSwipeIdlbl)
    EditCardSwipeIdlbl=[[UILabel alloc] init];
    EditCardSwipeIdlbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 30,Employee, 50);
    [EditCardSwipeIdlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditCardSwipeIdlbl setBackgroundColor:[UIColor clearColor]];
    [EditCardSwipeIdlbl setTextColor:[UIColor whiteColor]];
    [EditCardSwipeIdlbl setText:@"Card Swipe ID"];
    EditCardSwipeIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditCardSwipeIdlbl.numberOfLines = 2;
    [EditCardSwipeIdlbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditCardSwipeIdlbl];
     if (!EditCardSwipeIdField)
    EditCardSwipeIdField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditCardSwipeIdField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 35,Employee, 40);
    EditCardSwipeIdField.delegate=self;
    UIView *paddingview6=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditCardSwipeIdField.leftView = paddingview6;
    EditCardSwipeIdField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditCardSwipeIdField.leftViewMode = UITextFieldViewModeAlways;
    [EditCardSwipeIdField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditCardSwipeIdField.text=swipecard;
    [EditCardSwipeIdField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditCardSwipeIdField];
     if (!EditCustomerLbl)
    EditCustomerLbl=[[UILabel alloc] init];
    EditCustomerLbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 90,Employee, 50);
    [EditCustomerLbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditCustomerLbl setBackgroundColor:[UIColor clearColor]];
    [EditCustomerLbl setTextColor:[UIColor whiteColor]];
    [EditCustomerLbl setText:@"Customer"];
    EditCustomerLbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditCustomerLbl.numberOfLines = 2;
    [EditCustomerLbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditCustomerLbl];
     if (!EditCustomerField)
    EditCustomerField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditCustomerField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 95,Employee, 40);
    EditCustomerField.delegate=self;
    UIView *paddingview7=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditCustomerField.leftView = paddingview7;
    EditCustomerField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditCustomerField.leftViewMode = UITextFieldViewModeAlways;
    [EditCustomerField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditCustomerField.text=custmer;
    [EditCustomerField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditCustomerField];
     if (!EditHoulrywagelbl)
    EditHoulrywagelbl=[[UILabel alloc] init];
    EditHoulrywagelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 150,Employee, 50);
    [EditHoulrywagelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditHoulrywagelbl setBackgroundColor:[UIColor clearColor]];
    [EditHoulrywagelbl setTextColor:[UIColor whiteColor]];
    [EditHoulrywagelbl setText:@"Houly Wage"];
    EditHoulrywagelbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditHoulrywagelbl.numberOfLines = 2;
    [EditHoulrywagelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditHoulrywagelbl];
     if (!EditHoulrywageField)
    EditHoulrywageField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditHoulrywageField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 155,Employee, 40);
    EditHoulrywageField.delegate=self;
    UIView *paddingview8=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditHoulrywageField.leftView = paddingview8;
    EditHoulrywageField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditHoulrywageField.leftViewMode = UITextFieldViewModeAlways;
    [EditHoulrywageField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditHoulrywageField.text=houly;
    EditHoulrywageField.keyboardType=UIKeyboardTypeNumberPad;
    [EditHoulrywageField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditHoulrywageField];
     if (!EditDisablelbl)
    EditDisablelbl=[[UILabel alloc] init];
    EditDisablelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 210,Employee+80, 50);
    [EditDisablelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditDisablelbl setBackgroundColor:[UIColor clearColor]];
    [EditDisablelbl setTextColor:[UIColor whiteColor]];
    
    [EditDisablelbl setText:@"Disable this Employee"];
    
    [EditDisablelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditDisablelbl];
     if (!EditdisableBtn)
    EditdisableBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditdisableBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditDisablelbl.frame.size.width, 220,30, 30);
    [EditdisableBtn addTarget:self action:@selector(EditDisableBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditdisableBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditdisableBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [EditdisableBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [EditemployeeView addSubview:EditdisableBtn];
     if (!Editadministrativelbl)
    Editadministrativelbl=[[UILabel alloc] init];
    Editadministrativelbl.frame=CGRectMake(E-90, 270,Employee+100, 50);
    [Editadministrativelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Editadministrativelbl setBackgroundColor:[UIColor clearColor]];
    [Editadministrativelbl setTextColor:[UIColor whiteColor]];
    
    [Editadministrativelbl setText:@"Administrative Card Access"];
    
    [Editadministrativelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:Editadministrativelbl];
    if (!EditadministrativeBtn)
    EditadministrativeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditadministrativeBtn.frame=CGRectMake(E-80+Editadministrativelbl.frame.size.width, 280,30, 30);
    [EditadministrativeBtn addTarget:self action:@selector(EditAdministrativeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditadministrativeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditadministrativeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [EditadministrativeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [EditemployeeView addSubview:EditadministrativeBtn];
    
     if (!EditTakeccTipslbl)
    EditTakeccTipslbl=[[UILabel alloc] init];
    EditTakeccTipslbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 250,Employee+80, 100);
    [EditTakeccTipslbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditTakeccTipslbl setBackgroundColor:[UIColor clearColor]];
    [EditTakeccTipslbl setTextColor:[UIColor whiteColor]];
    
    [EditTakeccTipslbl setText:@"Take CC Tips in Cash at End of Shift"];
    EditTakeccTipslbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditTakeccTipslbl.numberOfLines = 2;
    [EditTakeccTipslbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditTakeccTipslbl];
    if (!EditTakeccTipsBtn)
    EditTakeccTipsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditTakeccTipsBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditTakeccTipslbl.frame.size.width+20, 280,30, 30);
    [EditTakeccTipsBtn addTarget:self action:@selector(EditTakecctipsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditTakeccTipsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditTakeccTipsBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [EditTakeccTipsBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [EditemployeeView addSubview:EditTakeccTipsBtn];
    
    if ([Disable isEqualToString:@"yes"])
    {
        EditdisableBtn.selected=YES;
        Disable=@"yes";
    }
    else{
        EditdisableBtn.selected=NO;
        Disable=@"no";
        
    }
    if ([administrative isEqualToString:@"yes"])
    {
        EditadministrativeBtn.selected=YES;
        administrative=@"yes";
    }
    else{
        EditadministrativeBtn.selected=NO;
        administrative=@"no";
        
    }
    if ([Cctips isEqualToString:@"yes"])
    {
        EditTakeccTipsBtn.selected=YES;
        Cctips=@"yes";
    }
    else{
        EditTakeccTipsBtn.selected=NO;
        Cctips=@"no";
        
    }
    CGFloat wdth=(EditemployeeView.frame.size.width)/5;
    CGFloat xvalue=wdth/4;
    NSArray *array2;
    for (int k=0; k<4; k++)
    {
        EditEmployeeInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        if (!array2)
        array2=[[NSArray alloc]initWithObjects:@"Permissions",@"Personal Info",@"Payroll Info",@"Store Info",nil];
        [EditEmployeeInfoBtn setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
        [EditEmployeeInfoBtn setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        EditEmployeeInfoBtn.frame=CGRectMake(xvalue,340,wdth+5, 40);
        
        [EditEmployeeInfoBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
        EditEmployeeInfoBtn.tag=k+100;
        [EditEmployeeInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [EditemployeeView addSubview:EditEmployeeInfoBtn];
        xvalue=xvalue+wdth+15;
        
    }
    @autoreleasepool {
        EditSaveEmployeeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        EditSaveEmployeeBtn.frame=CGRectMake(Employee+100, 450, 80, 30);
        [EditSaveEmployeeBtn addTarget:self action:@selector(SaveEditEmployeeData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [EditSaveEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [EditSaveEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [EditemployeeView addSubview:EditSaveEmployeeBtn];
        
        EditCancelEmployeeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        EditCancelEmployeeBtn.frame=CGRectMake(Employee+220, 450, 80, 30);
        [EditCancelEmployeeBtn addTarget:self action:@selector(CancelEditEmployeeData) forControlEvents:UIControlEventTouchUpInside];
        [EditCancelEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [EditCancelEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [EditemployeeView addSubview:EditCancelEmployeeBtn];
    }
  
}
- (IBAction)employee_duplicateButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    if (!EditEmployeePopUp)
    EditEmployeePopUp=[[UIView alloc]init];
    if (isLandScope) {
        EditEmployeePopUp.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        EditEmployeePopUp.frame=CGRectMake(0, 0, 768, 1024);
    }
    [EditEmployeePopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:EditEmployeePopUp];
    
     if (!EditemployeeView)
    EditemployeeView=[[UIScrollView alloc]init];
    if (isLandScope) {
        EditemployeeView.frame=CGRectMake(20, 100, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-200);
    }else{
        EditemployeeView.frame=CGRectMake(20, 200, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-500);
    }
    EditemployeeView.contentSize=CGSizeMake(EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height+100);
    
    [EditemployeeView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [EditemployeeView.layer setBorderWidth:2.0];
    [EditemployeeView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [EditEmployeePopUp addSubview:EditemployeeView];
    
    
    NSString *Dept=[EmDepartmentsArray objectAtIndex:selectedrow];
    NSString *emID=[EmployeeIdsArray objectAtIndex:selectedrow];
    
    EmpPassword=[passwordsArray objectAtIndex:selectedrow];
    NSString *DisName=[DisplayNamesArray objectAtIndex:selectedrow];
    NSString *swipecard=[cardswipeidsArray objectAtIndex:selectedrow];
    NSString *custmer=[EmCustomersArray objectAtIndex:selectedrow];
    NSString *houly=[houlrywagesArray objectAtIndex:selectedrow];
    
    
    Disable=[disablesArray objectAtIndex:selectedrow];
    administrative=[administativesArray objectAtIndex:selectedrow];
    Cctips=[CctipsArray objectAtIndex:selectedrow];
    
    NSString *querySQL = [NSString stringWithFormat:@"SELECT emp_store_name,emp_store_id FROM employee_store WHERE employee_employee_id='%@'",emID];
    NSMutableArray *empstoresArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:empstoresArray];
    SelectedStoredataArray=[[NSMutableArray alloc]init];
    SeleCtedStoreIdsArray=[[NSMutableArray alloc]init];
    
    DBstorenamesArray=[[NSMutableArray alloc]init];
    BdStoreidsArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for (NSDictionary *myDict in empstoresArray )
        {
            [DBstorenamesArray addObject:[myDict objectForKey:@"emp_store_name"]];
            
            [BdStoreidsArray addObject:[myDict objectForKey:@"emp_store_id"]];
        }
    }
    Name=[NamesArray objectAtIndex:selectedrow];
    ID=[IDsArray objectAtIndex:selectedrow];
    Email=[EmailsArray objectAtIndex:selectedrow];
    Phonenumber=[PhonenumbersArray objectAtIndex:selectedrow];
    Birthday=[BirthdaysArray objectAtIndex:selectedrow];
    Address=[AddresssArray objectAtIndex:selectedrow];
    City=[CitysArray objectAtIndex:selectedrow];
    Country=[CountrysArray objectAtIndex:selectedrow];
    state=[statesArray objectAtIndex:selectedrow];
    Zipcode=[ZipcodesArray objectAtIndex:selectedrow];
    
    Exclude=[ExcludesArray objectAtIndex:selectedrow];
    federal=[federalsArray objectAtIndex:selectedrow];
    federalAmount=[federalAmountsArray objectAtIndex:selectedrow];
    stateallowances=[stateallowancessArray objectAtIndex:selectedrow];
    stateAmount=[stateAmountsArray objectAtIndex:selectedrow];
    credits=[creditssArray objectAtIndex:selectedrow];
    Exempt=[DataExemptsArray objectAtIndex:selectedrow];
    Filling=[DataFillingsArray objectAtIndex:selectedrow];
    
    
    inventory=[inventorysArray objectAtIndex:selectedrow];
    reports=[reportssArray objectAtIndex:selectedrow];
    settings=[settingssArray objectAtIndex:selectedrow];
    allowexit=[allowexitsArray objectAtIndex:selectedrow];
    deleteitems=[deleteitemssArray objectAtIndex:selectedrow];
    endTransactions=[endTransactionssArray objectAtIndex:selectedrow];
    forceCreditcard=[forceCreditcardsArray objectAtIndex:selectedrow];
    customers=[customerssArray objectAtIndex:selectedrow];
    invoicediscounts=[invoicediscountssArray objectAtIndex:selectedrow];
    pricechnages=[pricechnagessArray objectAtIndex:selectedrow];
    
    payouts=[payoutssArray objectAtIndex:selectedrow];
    voidinvoices=[voidinvoicessArray objectAtIndex:selectedrow];
    hold=[holdsArray objectAtIndex:selectedrow];
    endcash=[endcashsArray objectAtIndex:selectedrow];
   // // //NSLog(@"Permissions %@,%@,%@,%@,%@,%@,%@,%@",inventory,customers,reports,invoicediscounts,settings,pricechnages,allowexit,payouts);
    
    CGFloat Employee=(EditemployeeView.frame.size.width)/4;
    CGFloat E=(Employee/2)+20;
    if (!EditDepartmentlbl)
    EditDepartmentlbl=[[UILabel alloc] init];
    EditDepartmentlbl.frame=CGRectMake(E-90, 30,Employee, 50);
    
    [EditDepartmentlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditDepartmentlbl setBackgroundColor:[UIColor clearColor]];
    [EditDepartmentlbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentlbl setText:@"Department"];
    EditDepartmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditDepartmentlbl.numberOfLines = 2;
    [EditDepartmentlbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditDepartmentlbl];
    
    
    if (!EditDepartmentBtn)
    EditDepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditDepartmentBtn.frame=CGRectMake(Employee-5, 35,Employee, 40);
    [EditDepartmentBtn addTarget:self action:@selector(EditDepartmentBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditDepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditDepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditDepartmentBtn setTitle:Dept forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [EditemployeeView addSubview:EditDepartmentBtn];
     if (!EditDepartmentListTable)
    EditDepartmentListTable = [[UITableView alloc] initWithFrame:CGRectMake(Employee-5, 75,Employee, 100) style:UITableViewStylePlain];
    EditDepartmentListTable.backgroundColor=[UIColor whiteColor];
    EditDepartmentListTable.delegate = self;
    EditDepartmentListTable.dataSource = self;
    EditDepartmentListTable.scrollEnabled = YES;
    EditDepartmentListTable.hidden=YES;
    [EditDepartmentListTable.layer setBorderWidth: 1.0];
    [EditDepartmentListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditemployeeView addSubview:EditDepartmentListTable];
    if (!EditEmployeeIdLbl)
    EditEmployeeIdLbl=[[UILabel alloc] init];
    EditEmployeeIdLbl.frame=CGRectMake(E-90, 90,Employee, 50);
    [EditEmployeeIdLbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditEmployeeIdLbl setBackgroundColor:[UIColor clearColor]];
    [EditEmployeeIdLbl setTextColor:[UIColor whiteColor]];
    [EditEmployeeIdLbl setText:@"Employee ID"];
    EditEmployeeIdLbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditEmployeeIdLbl.numberOfLines = 2;
    [EditEmployeeIdLbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditEmployeeIdLbl];
    if (!DuplicateEmployeeIdField)
    DuplicateEmployeeIdField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    DuplicateEmployeeIdField.frame=CGRectMake(Employee-5, 95,Employee, 40);
    DuplicateEmployeeIdField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    DuplicateEmployeeIdField.leftView = paddingview2;
    DuplicateEmployeeIdField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DuplicateEmployeeIdField.leftViewMode = UITextFieldViewModeAlways;
    [DuplicateEmployeeIdField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    DuplicateEmployeeIdField.text=emID;
    [DuplicateEmployeeIdField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:DuplicateEmployeeIdField];
    if (!EditPasswordlbl)
    EditPasswordlbl=[[UILabel alloc] init];
    EditPasswordlbl.frame=CGRectMake(E-90, 150,Employee, 50);
    
    [EditPasswordlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditPasswordlbl setBackgroundColor:[UIColor clearColor]];
    [EditPasswordlbl setTextColor:[UIColor whiteColor]];
    [EditPasswordlbl setText:@"Password"];
    EditPasswordlbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditPasswordlbl.numberOfLines = 2;
    [EditPasswordlbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditPasswordlbl];
      if (!EditPasswordField)
    EditPasswordField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditPasswordField.frame=CGRectMake(Employee-5, 155,Employee, 40);
    EditPasswordField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditPasswordField.leftView = paddingview3;
    EditPasswordField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditPasswordField.leftViewMode = UITextFieldViewModeAlways;
    [EditPasswordField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditPasswordField.text=@"";
    [EditPasswordField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditPasswordField];
     if (!EditDisplaynamelbl)
    EditDisplaynamelbl=[[UILabel alloc] init];
    EditDisplaynamelbl.frame=CGRectMake(E-90, 210,Employee, 50);
    
    [EditDisplaynamelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditDisplaynamelbl setBackgroundColor:[UIColor clearColor]];
    [EditDisplaynamelbl setTextColor:[UIColor whiteColor]];
    [EditDisplaynamelbl setText:@"DisplayName"];
    EditDisplaynamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditDisplaynamelbl.numberOfLines = 2;
    [EditDisplaynamelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditDisplaynamelbl];
    if (!EditDisplaynameField)
    EditDisplaynameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditDisplaynameField.frame=CGRectMake(Employee-5, 215,Employee, 40);
    EditDisplaynameField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditDisplaynameField.leftView = paddingview4;
    EditDisplaynameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditDisplaynameField.leftViewMode = UITextFieldViewModeAlways;
    [EditDisplaynameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditDisplaynameField.text=DisName;
    [EditDisplaynameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditDisplaynameField];
    
    if (!EditCardSwipeIdlbl)
    EditCardSwipeIdlbl=[[UILabel alloc] init];
    EditCardSwipeIdlbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 30,Employee, 50);
    
    [EditCardSwipeIdlbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditCardSwipeIdlbl setBackgroundColor:[UIColor clearColor]];
    [EditCardSwipeIdlbl setTextColor:[UIColor whiteColor]];
    [EditCardSwipeIdlbl setText:@"Card Swipe ID"];
    EditCardSwipeIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditCardSwipeIdlbl.numberOfLines = 2;
    [EditCardSwipeIdlbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditCardSwipeIdlbl];
    if (!EditCardSwipeIdField)
    EditCardSwipeIdField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditCardSwipeIdField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 35,Employee, 40);
    EditCardSwipeIdField.delegate=self;
    UIView *paddingview6=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditCardSwipeIdField.leftView = paddingview6;
    EditCardSwipeIdField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditCardSwipeIdField.leftViewMode = UITextFieldViewModeAlways;
    [EditCardSwipeIdField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditCardSwipeIdField.text=swipecard;
    [EditCardSwipeIdField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditCardSwipeIdField];
    if (!EditCustomerLbl)
    EditCustomerLbl=[[UILabel alloc] init];
    EditCustomerLbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 90,Employee, 50);
    [EditCustomerLbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditCustomerLbl setBackgroundColor:[UIColor clearColor]];
    [EditCustomerLbl setTextColor:[UIColor whiteColor]];
    [EditCustomerLbl setText:@"Customer"];
    EditCustomerLbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditCustomerLbl.numberOfLines = 2;
    [EditCustomerLbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditCustomerLbl];
     if (!EditCustomerField)
    EditCustomerField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditCustomerField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 95,Employee, 40);
    EditCustomerField.delegate=self;
    UIView *paddingview7=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditCustomerField.leftView = paddingview7;
    EditCustomerField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditCustomerField.leftViewMode = UITextFieldViewModeAlways;
    [EditCustomerField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditCustomerField.text=custmer;
    [EditCustomerField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditCustomerField];
     if (!EditHoulrywagelbl)
    EditHoulrywagelbl=[[UILabel alloc] init];
    EditHoulrywagelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 150,Employee, 50);
    [EditHoulrywagelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditHoulrywagelbl setBackgroundColor:[UIColor clearColor]];
    [EditHoulrywagelbl setTextColor:[UIColor whiteColor]];
    [EditHoulrywagelbl setText:@"Houly Wage"];
    EditHoulrywagelbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditHoulrywagelbl.numberOfLines = 2;
    [EditHoulrywagelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditHoulrywagelbl];
     if (!EditHoulrywageField)
    EditHoulrywageField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditHoulrywageField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 155,Employee, 40);
    EditHoulrywageField.delegate=self;
    UIView *paddingview8=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditHoulrywageField.leftView = paddingview8;
    EditHoulrywageField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditHoulrywageField.leftViewMode = UITextFieldViewModeAlways;
    [EditHoulrywageField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditHoulrywageField.text=houly;
    EditHoulrywageField.keyboardType=UIKeyboardTypeNumberPad;
    [EditHoulrywageField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditemployeeView addSubview:EditHoulrywageField];
      if (!EditDisablelbl)
    EditDisablelbl=[[UILabel alloc] init];
    EditDisablelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 210,Employee+80, 50);
    [EditDisablelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditDisablelbl setBackgroundColor:[UIColor clearColor]];
    [EditDisablelbl setTextColor:[UIColor whiteColor]];
    
    [EditDisablelbl setText:@"Disable this Employee"];
    
    [EditDisablelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditDisablelbl];
    if (!EditdisableBtn)
    EditdisableBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditdisableBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditDisablelbl.frame.size.width, 220,30, 30);
    [EditdisableBtn addTarget:self action:@selector(EditDisableBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditdisableBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditdisableBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [EditdisableBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [EditemployeeView addSubview:EditdisableBtn];
     if (!Editadministrativelbl)
    Editadministrativelbl=[[UILabel alloc] init];
    Editadministrativelbl.frame=CGRectMake(E-90, 270,Employee+100, 50);
    [Editadministrativelbl setFont:[UIFont systemFontOfSize:22.0f]];
    [Editadministrativelbl setBackgroundColor:[UIColor clearColor]];
    [Editadministrativelbl setTextColor:[UIColor whiteColor]];
    
    [Editadministrativelbl setText:@"Administrative Card Access"];
    
    [Editadministrativelbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:Editadministrativelbl];
    if (!EditadministrativeBtn)
    EditadministrativeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditadministrativeBtn.frame=CGRectMake(E-80+Editadministrativelbl.frame.size.width, 280,30, 30);
    [EditadministrativeBtn addTarget:self action:@selector(EditAdministrativeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditadministrativeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditadministrativeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [EditadministrativeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [EditemployeeView addSubview:EditadministrativeBtn];
    
     if (!EditTakeccTipslbl)
    EditTakeccTipslbl=[[UILabel alloc] init];
    EditTakeccTipslbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 250,Employee+80, 100);
    [EditTakeccTipslbl setFont:[UIFont systemFontOfSize:22.0f]];
    [EditTakeccTipslbl setBackgroundColor:[UIColor clearColor]];
    [EditTakeccTipslbl setTextColor:[UIColor whiteColor]];
    
    [EditTakeccTipslbl setText:@"Take CC Tips in Cash at End of Shift"];
    EditTakeccTipslbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditTakeccTipslbl.numberOfLines = 2;
    [EditTakeccTipslbl setTextAlignment:NSTextAlignmentLeft];
    [EditemployeeView addSubview:EditTakeccTipslbl];
    if (!EditTakeccTipsBtn)
    EditTakeccTipsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    EditTakeccTipsBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditTakeccTipslbl.frame.size.width+20, 280,30, 30);
    [EditTakeccTipsBtn addTarget:self action:@selector(EditTakecctipsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [EditTakeccTipsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditTakeccTipsBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [EditTakeccTipsBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [EditemployeeView addSubview:EditTakeccTipsBtn];
    
    if ([Disable isEqualToString:@"yes"])
    {
        EditdisableBtn.selected=YES;
        Disable=@"yes";
    }
    else{
        EditdisableBtn.selected=NO;
        Disable=@"no";
        
    }
    if ([administrative isEqualToString:@"yes"])
    {
        EditadministrativeBtn.selected=YES;
        administrative=@"yes";
    }
    else{
        EditadministrativeBtn.selected=NO;
        administrative=@"no";
        
    }
    if ([Cctips isEqualToString:@"yes"])
    {
        EditTakeccTipsBtn.selected=YES;
        Cctips=@"yes";
    }
    else{
        EditTakeccTipsBtn.selected=NO;
        Cctips=@"no";
        
    }
    NSArray *array2;
    CGFloat wdth=(EditemployeeView.frame.size.width)/5;
    CGFloat xvalue=wdth/4;
    for (int k=0; k<4; k++)
    {
        EditEmployeeInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        if (!array2)
        array2=[[NSArray alloc]initWithObjects:@"Permissions",@"Personal Info",@"Payroll Info",@"Store Info",nil];
        [EditEmployeeInfoBtn setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
        [EditEmployeeInfoBtn setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        EditEmployeeInfoBtn.frame=CGRectMake(xvalue,340,wdth+5, 40);
        
        [EditEmployeeInfoBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
        EditEmployeeInfoBtn.tag=k+100;
        [EditEmployeeInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [EditemployeeView addSubview:EditEmployeeInfoBtn];
        xvalue=xvalue+wdth+15;
        
    }
    @autoreleasepool {
        EditSaveEmployeeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        EditSaveEmployeeBtn.frame=CGRectMake(Employee+100, 450, 80, 30);
        [EditSaveEmployeeBtn addTarget:self action:@selector(SaveDuplicateEmployeeData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [EditSaveEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [EditSaveEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [EditemployeeView addSubview:EditSaveEmployeeBtn];
        
        EditCancelEmployeeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        EditCancelEmployeeBtn.frame=CGRectMake(Employee+220, 450, 80, 30);
        [EditCancelEmployeeBtn addTarget:self action:@selector(CancelEditEmployeeData) forControlEvents:UIControlEventTouchUpInside];
        [EditCancelEmployeeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [EditCancelEmployeeBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [EditemployeeView addSubview:EditCancelEmployeeBtn];
    }
   
}
- (IBAction)employee_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    SelectedEmployee=but.tag-1;
    DeleteEmployeeAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Employee Data" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [DeleteEmployeeAlert show];
}

-(void)EditDepartmentBtnClicked
{
    if (EditDepartmentListTable.hidden==1)
    {
        EditPasswordField.hidden=YES;
        EditEmployeeIdField.hidden=YES;
         DuplicateEmployeeIdField.hidden=YES;
        EditDepartmentListTable.hidden=NO;
        
        
    }
    else if (EditDepartmentListTable.hidden==0)
    {
        EditPasswordField.hidden=NO;
        EditEmployeeIdField.hidden=NO;
        DuplicateEmployeeIdField.hidden=NO;
        [EditDepartmentListTable setHidden:YES];
        
    }
}
-(void)EditDisableBtnClicked
{
    if (EditdisableBtn.selected)
    {
        [EditdisableBtn setSelected:NO];
        Disable=@"no";
    }
    else if(!EditdisableBtn.selected)
    {
        [EditdisableBtn setSelected:YES];
        Disable=@"yes";
    }
    
}

-(void)EditTakecctipsBtnClicked
{
    if (EditTakeccTipsBtn.selected)
    {
        [EditTakeccTipsBtn setSelected:NO];
        Cctips=@"no";
    }
    else if(!EditTakeccTipsBtn.selected)
    {
        [EditTakeccTipsBtn setSelected:YES];
        Cctips=@"yes";
    }
}
-(void)EditAdministrativeBtnClicked
{
    if (EditadministrativeBtn.selected)
    {
        [EditadministrativeBtn setSelected:NO];
        administrative=@"no";
    }
    else if(!EditadministrativeBtn.selected)
    {
        [EditadministrativeBtn setSelected:YES];
        administrative=@"yes";
    }
}

-(void)infoButton2Clicked:(UIButton *)sender
{
    
    if ([administrative isEqualToString:@"no"])
    {
        inventory=@"no";
        reports=@"no";
        settings=@"no";
        allowexit=@"no";
        deleteitems=@"no";
        endTransactions=@"no";
        forceCreditcard=@"no";
        
        customers=@"no";
        invoicediscounts=@"no";
        pricechnages=@"no";
        payouts=@"no";
        voidinvoices=@"no";
        hold=@"no";
        endcash=@"no";
        
    }else  if ([administrative isEqualToString:@"yes"]){
        inventory=@"yes";
        reports=@"yes";
        settings=@"yes";
        allowexit=@"yes";
        deleteitems=@"yes";
        endTransactions=@"yes";
        forceCreditcard=@"yes";
        
        customers=@"yes";
        invoicediscounts=@"yes";
        pricechnages=@"yes";
        payouts=@"yes";
        voidinvoices=@"yes";
        hold=@"yes";
        endcash=@"yes";
        
    }
    
    
    NSInteger selectedBtn=sender.tag;
    if (selectedBtn==100){
        PermissionsPopupView=[[UIView alloc]init];
        if (isLandScope) {
            PermissionsPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            PermissionsPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PermissionsPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PermissionsPopupView];
        
        PermissionsView=[[UIScrollView alloc] init];
        if (isLandScope) {
            
            PermissionsView.frame=CGRectMake(25, 50, PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height-100);
        }
        else
        {
            PermissionsView.frame=CGRectMake(25, 100, PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height-300);
        }
        //PermissionsView.contentSize=CGSizeMake(PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height+200);
        [PermissionsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [PermissionsView.layer setBorderWidth:2.0];
        [PermissionsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PermissionsPopupView addSubview:PermissionsView];
        
        CGFloat permissionwidth=(PermissionsView.frame.size.width)/4;
        CGFloat perm=(permissionwidth/2);
        PermissonsTextlbl=[[UILabel alloc] init];
        PermissonsTextlbl.frame=CGRectMake(permissionwidth+100, 10,permissionwidth+100, 40);
        
        [PermissonsTextlbl setFont:[UIFont systemFontOfSize:28.0f]];
        [PermissonsTextlbl setBackgroundColor:[UIColor clearColor]];
        [PermissonsTextlbl setTextColor:[UIColor whiteColor]];
        
        [PermissonsTextlbl setText:@"Permissions"];
        [PermissonsTextlbl setTextAlignment:NSTextAlignmentLeft];
        [PermissionsView addSubview:PermissonsTextlbl];
        
        int s=100;
        NSArray *labelArray;
        for (int i=0; i<7; i++)
        {
            
            PermissionLbl=[[UILabel alloc] init];
            PermissionLbl.frame=CGRectMake(perm-60, s,permissionwidth+80, 40);
            
            PermissionLbl.tag=i+100;
            [PermissionLbl setFont:[UIFont systemFontOfSize:24.0f]];
            [PermissionLbl setBackgroundColor:[UIColor clearColor]];
            [PermissionLbl setTextColor:[UIColor whiteColor]];
            if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Inventory",@"Reports",@"Settings",@"Allow Exit",@"Delete Items",@"End Transactions",@"Force CreditCard",nil];
            [PermissionLbl setText:[labelArray objectAtIndex:i]];
            [PermissionLbl setTextAlignment:NSTextAlignmentLeft];
            [PermissionsView addSubview:PermissionLbl];
            
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            Myswitch=[[UISwitch alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            Myswitch.frame=CGRectMake(PermissionLbl.frame.size.width+10, s+5,permissionwidth, 40);
            
            Myswitch.tag=i+100;
            
            
            [Myswitch addTarget:self action:@selector(MyswitchClicked:) forControlEvents:UIControlEventValueChanged];
            if (Myswitch.tag==100)
            {
                if ([inventory isEqualToString:@"yes"])
                { [Myswitch setOn:TRUE animated:YES];
                    
                    inventory=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    inventory=@"no";
                    
                }
            }
            
            if (Myswitch.tag==101)
            {
                if ([reports isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    reports=@"yes";
                }
                else{
                    
                    
                    [Myswitch setOn:FALSE animated:YES];
                    reports=@"no";
                    
                }
            }
            if (Myswitch.tag==102)
            {
                if ([settings isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    
                    settings=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    
                    settings=@"no";
                    
                }
            }
            if (Myswitch.tag==103)
            {
                if ([allowexit isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    allowexit=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    
                    allowexit=@"no";
                    
                }
            }
            if (Myswitch.tag==104)
            {
                if ([deleteitems isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    
                    deleteitems=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    deleteitems=@"no";
                    
                }
            }
            if (Myswitch.tag==105)
            {
                if ([endTransactions isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    
                    endTransactions=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    endTransactions=@"no";
                    
                }
            }
            if (Myswitch.tag==106)
            {
                if ([forceCreditcard isEqualToString:@"yes"])
                {
                    [Myswitch setOn:TRUE animated:YES];
                    
                    forceCreditcard=@"yes";
                }
                else{
                    [Myswitch setOn:FALSE animated:YES];
                    forceCreditcard=@"no";
                    
                }
            }
            
            [PermissionsView addSubview:Myswitch];
            
            s=s+60;
            
        }
        int m=100;
        NSArray *labelArray2;
        for (int i=0; i<7; i++)
        {
            
            Permissionlbl2=[[UILabel alloc] init];
            Permissionlbl2.frame=CGRectMake(perm+PermissionLbl.frame.size.width, m,permissionwidth+80, 40);
            
            Permissionlbl2.tag=i+100;
            [Permissionlbl2 setFont:[UIFont systemFontOfSize:24.0f]];
            [Permissionlbl2 setBackgroundColor:[UIColor clearColor]];
            [Permissionlbl2 setTextColor:[UIColor whiteColor]];
             if (!labelArray2)
            labelArray2=[[NSArray alloc] initWithObjects:@"Customers",@"Invoice Discounts",@"Invoice Price Changes",@"Vendor Payouts",@"Void Invoices",@"Hold&Print",@"End Cash Transactions",nil];
            [Permissionlbl2 setText:[labelArray objectAtIndex:i]];
            [Permissionlbl2 setTextAlignment:NSTextAlignmentLeft];
            [PermissionsView addSubview:Permissionlbl2];
            
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            SecondSwitch=[[UISwitch alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            SecondSwitch.frame=CGRectMake(perm+PermissionLbl.frame.size.width-30+Permissionlbl2.frame.size.width+40, m+5,permissionwidth, 40);
            
            SecondSwitch.tag=i+100;
            
            
            [SecondSwitch addTarget:self action:@selector(SecondswitchClicked:) forControlEvents:UIControlEventValueChanged];
            if (SecondSwitch.tag==100)
            {
                if ([customers isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    customers=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    customers=@"no";
                    
                }
            }
            if (SecondSwitch.tag==101)
            {
                if ([invoicediscounts isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    invoicediscounts=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    invoicediscounts=@"no";
                    
                }
            }
            if (SecondSwitch.tag==102)
            {
                if ([pricechnages isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    pricechnages=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    pricechnages=@"no";
                    
                }
            }
            if (SecondSwitch.tag==103)
            {
                if ([payouts isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    payouts=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    payouts=@"no";
                    
                }
            }
            if (SecondSwitch.tag==104)
            {
                if ([voidinvoices isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    voidinvoices=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    voidinvoices=@"no";
                    
                }
            }
            if (SecondSwitch.tag==105)
            {
                if ([hold isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    hold=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    hold=@"no";
                    
                }
            }
            if (SecondSwitch.tag==106)
            {
                if ([endcash isEqualToString:@"yes"])
                {
                    [SecondSwitch setOn:TRUE animated:YES];
                    endcash=@"yes";
                }
                else{
                    [SecondSwitch setOn:FALSE animated:YES];
                    endcash=@"no";
                    
                }
            }
            
            [PermissionsView addSubview:SecondSwitch];
            
            m=m+60;
            
        }
        @autoreleasepool {
            SavePermissionBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavePermissionBtn.frame=CGRectMake(permissionwidth+100, 580, 80, 30);
            [SavePermissionBtn addTarget:self action:@selector(SavePermissions) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavePermissionBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavePermissionBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [PermissionsView addSubview:SavePermissionBtn];
            
            CancelPermissionsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelPermissionsBtn.frame=CGRectMake(permissionwidth+220, 580, 80, 30);
            [CancelPermissionsBtn addTarget:self action:@selector(CancelPermissions) forControlEvents:UIControlEventTouchUpInside];
            [CancelPermissionsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelPermissionsBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [PermissionsView addSubview:CancelPermissionsBtn];
        }
    
        
    }else if (selectedBtn==102){
        PayrollPopUpView=[[UIView alloc]init];
        if (isLandScope) {
            PayrollPopUpView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            PayrollPopUpView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PayrollPopUpView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PayrollPopUpView];
        
        PayrollView=[[UIScrollView alloc] init];
        if (isLandScope)
        {
            PayrollView.frame=CGRectMake(25, 50, PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height-100);
        }else{
            PayrollView.frame=CGRectMake(25, 100, PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height-300);
        }
        PayrollView.contentSize=CGSizeMake(PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height+200);
        [PayrollView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [PayrollView.layer setBorderWidth:2.0];
        [PayrollView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PayrollPopUpView addSubview:PayrollView];
        
        CGFloat payrollwidth=(PayrollView.frame.size.width)/2;
        CGFloat pay=(payrollwidth/2);
        
        PayrollTextLbl=[[UILabel alloc] init];
        PayrollTextLbl.frame=CGRectMake(payrollwidth-80, 10,payrollwidth+100, 40);
        
        [PayrollTextLbl setFont:[UIFont systemFontOfSize:25.0f]];
        [PayrollTextLbl setBackgroundColor:[UIColor clearColor]];
        [PayrollTextLbl setTextColor:[UIColor whiteColor]];
        
        [PayrollTextLbl setText:@"Payroll Details"];
        [PayrollTextLbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:PayrollTextLbl];
        
        Excludelbl=[[UILabel alloc] init];
        Excludelbl.frame=CGRectMake(pay-160, 60,payrollwidth+80, 40);
        [Excludelbl setFont:[UIFont systemFontOfSize:22.0f]];
        [Excludelbl setBackgroundColor:[UIColor clearColor]];
        [Excludelbl setTextColor:[UIColor whiteColor]];
        
        [Excludelbl setText:@"Exclude From Payroll"];
        Excludelbl.lineBreakMode = NSLineBreakByWordWrapping;
        Excludelbl.numberOfLines = 2;
        [Excludelbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:Excludelbl];
        
        ExcludeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ExcludeBtn.frame=CGRectMake(Excludelbl.frame.size.width-150, 65,30, 30);
        [ExcludeBtn addTarget:self action:@selector(ExcludeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        if ([Exclude isEqualToString:@"yes"])
        {
            ExcludeBtn.selected=YES;
            Exclude=@"yes";
        }
        else{
            ExcludeBtn.selected=NO;
            Exclude=@"no";
            
        }
        
        [ExcludeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [ExcludeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
        [ExcludeBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
        [PayrollView addSubview:ExcludeBtn];
        
        
        int k=100;
        NSArray *labelArray;
        for (int i=0; i<5; i++)
        {
            
            PayrollLbl=[[UILabel alloc] init];
            PayrollLbl.frame=CGRectMake(pay-175, k,payrollwidth+80, 40);
            
            PayrollLbl.tag=i+100;
            [PayrollLbl setFont:[UIFont systemFontOfSize:24.0f]];
            [PayrollLbl setBackgroundColor:[UIColor clearColor]];
            [PayrollLbl setTextColor:[UIColor whiteColor]];
            if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Federal Allowances",@"Additional Federal Withholding Amount",@"Sate Allowances",@"Additional State Withholding Amount",@"Sate Additional Credits",nil];
            [PayrollLbl setText:[labelArray objectAtIndex:i]];
            [PayrollLbl setTextAlignment:NSTextAlignmentLeft];
            [PayrollView addSubview:PayrollLbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            PayrollField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            PayrollField.frame=CGRectMake(PayrollLbl.frame.size.width-10, k,payrollwidth-80, 40);
            PayrollField.delegate=self;
            PayrollField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            PayrollField.leftView = paddingview;
            PayrollField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            PayrollField.leftViewMode = UITextFieldViewModeAlways;
            [PayrollField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (PayrollField.tag==100)
            {
                PayrollField.text=federal;
            }
            if (PayrollField.tag==101)
            {
                PayrollField.text=federalAmount;
            }
            if (PayrollField.tag==102)
            {
                PayrollField.text=stateallowances;
            }
            if (PayrollField.tag==103)
            {
                PayrollField.text=stateAmount;
            }
            if (PayrollField.tag==104)
            {
                PayrollField.text=credits;
            }
            
            [PayrollField addTarget:self action:@selector(PayrollinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [PayrollField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [PayrollView addSubview:PayrollField];
            
            k=k+60;
            
        }
        // //NSLog(@"%d",k);
        
        
        Exemptlbl=[[UILabel alloc] init];
        Exemptlbl.frame=CGRectMake(pay-175, 400,payrollwidth+80, 40);
        
        [Exemptlbl setFont:[UIFont systemFontOfSize:22.0f]];
        [Exemptlbl setBackgroundColor:[UIColor clearColor]];
        [Exemptlbl setTextColor:[UIColor whiteColor]];
        [Exemptlbl setText:@"Exempt"];
        Exemptlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Exemptlbl.numberOfLines = 2;
        [Exemptlbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:Exemptlbl];
        
        ExemptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        ExemptBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 400,payrollwidth-80, 40);
        [ExemptBtn addTarget:self action:@selector(ExemptBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [ExemptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [ExemptBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        //[DepartmentBtn setTitle:cardType forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PayrollView addSubview:ExemptBtn];
        
        ExemptsTable = [[UITableView alloc] initWithFrame:CGRectMake(Exemptlbl.frame.size.width-5, 440,payrollwidth-80, 100) style:UITableViewStylePlain];
        ExemptsTable.backgroundColor=[UIColor whiteColor];
        ExemptsTable.delegate = self;
        ExemptsTable.dataSource = self;
        ExemptsTable.scrollEnabled = YES;
        ExemptsTable.hidden=YES;
        [ExemptsTable.layer setBorderWidth: 1.0];
        [ExemptsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [PayrollView addSubview:ExemptsTable];
        
        FillingStatuslbl=[[UILabel alloc] init];
        FillingStatuslbl.frame=CGRectMake(pay-175, 460,payrollwidth+80, 40);
        
        [FillingStatuslbl setFont:[UIFont systemFontOfSize:22.0f]];
        [FillingStatuslbl setBackgroundColor:[UIColor clearColor]];
        [FillingStatuslbl setTextColor:[UIColor whiteColor]];
        [FillingStatuslbl setText:@"Filling Status"];
        FillingStatuslbl.lineBreakMode = NSLineBreakByWordWrapping;
        FillingStatuslbl.numberOfLines = 2;
        [FillingStatuslbl setTextAlignment:NSTextAlignmentLeft];
        [PayrollView addSubview:FillingStatuslbl];
        
        FillingBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        FillingBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 460,payrollwidth-80, 40);
        [FillingBtn addTarget:self action:@selector(FillingBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [FillingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [FillingBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        //[DepartmentBtn setTitle:cardType forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PayrollView addSubview:FillingBtn];
        
        FillingsTable = [[UITableView alloc] initWithFrame:CGRectMake(Exemptlbl.frame.size.width-5, 500,payrollwidth-80, 100) style:UITableViewStylePlain];
        FillingsTable.backgroundColor=[UIColor whiteColor];
        FillingsTable.delegate = self;
        FillingsTable.dataSource = self;
        FillingsTable.scrollEnabled = YES;
        FillingsTable.hidden=YES;
        [FillingsTable.layer setBorderWidth: 1.0];
        [FillingsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [PayrollView addSubview:FillingsTable];
        
        @autoreleasepool {
            SavePayrollBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavePayrollBtn.frame=CGRectMake(payrollwidth-100, 620, 80, 30);
            [SavePayrollBtn addTarget:self action:@selector(SavepayrollInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavePayrollBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavePayrollBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [PayrollView addSubview:SavePayrollBtn];
            
            CancelPayrollBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelPayrollBtn.frame=CGRectMake(payrollwidth+20, 620, 80, 30);
            [CancelPayrollBtn addTarget:self action:@selector(CancelpayrollInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelPayrollBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelPayrollBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [PayrollView addSubview:CancelPayrollBtn];
        }
      
        
    }else if (selectedBtn==101){
        PersonalInfoPopupView=[[UIView alloc]init];
        if (isLandScope) {
            PersonalInfoPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            PersonalInfoPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PersonalInfoPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PersonalInfoPopupView];
        
        PersonalInfoView=[[UIScrollView alloc] init];
        if (isLandScope) {
            
            PersonalInfoView.frame=CGRectMake(75, 50, PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height-100);
        }else{
            PersonalInfoView.frame=CGRectMake(75, 100, PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height-200);
            
        }
        PersonalInfoView.contentSize=CGSizeMake(PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height+200);
        [PersonalInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [PersonalInfoView.layer setBorderWidth:2.0];
        [PersonalInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PersonalInfoPopupView addSubview:PersonalInfoView];
        
        CGFloat fieldwidth=(PersonalInfoView.frame.size.width)/2;
        
        CGFloat o=(fieldwidth/2);
        PersonalInfotextlbl=[[UILabel alloc] init];
        PersonalInfotextlbl.frame=CGRectMake(fieldwidth-110, 10,fieldwidth+100, 40);
        
        [PersonalInfotextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [PersonalInfotextlbl setBackgroundColor:[UIColor clearColor]];
        [PersonalInfotextlbl setTextColor:[UIColor whiteColor]];
        
        [PersonalInfotextlbl setText:@"Personal Info Details"];
        [PersonalInfotextlbl setTextAlignment:NSTextAlignmentLeft];
        [PersonalInfoView addSubview:PersonalInfotextlbl];
        
        int d=70;
        NSArray *labelArray;
        for (int i=0; i<10; i++)
        {
            
            PersonalInfolbl=[[UILabel alloc] init];
            PersonalInfolbl.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            
            PersonalInfolbl.tag=i+100;
            [PersonalInfolbl setFont:[UIFont systemFontOfSize:24.0f]];
            [PersonalInfolbl setBackgroundColor:[UIColor clearColor]];
            [PersonalInfolbl setTextColor:[UIColor whiteColor]];
            if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Name*",@"SSN/ID* ",@"Store Email",@"Phone Number",@"Birthday",@"Address",@"City",@"Country",@"State",@"Zip/Postal Code",nil];
            [PersonalInfolbl setText:[labelArray objectAtIndex:i]];
            [PersonalInfolbl setTextAlignment:NSTextAlignmentLeft];
            [PersonalInfoView addSubview:PersonalInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            PersonalInfoField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            PersonalInfoField.frame=CGRectMake(PersonalInfolbl.frame.size.width-20, d,fieldwidth-80, 40);
            PersonalInfoField.delegate=self;
            PersonalInfoField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            PersonalInfoField.leftView = paddingview;
            PersonalInfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            PersonalInfoField.leftViewMode = UITextFieldViewModeAlways;
            [PersonalInfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            
            if (PersonalInfoField.tag==100)
            {
                PersonalInfoField.text=Name;
            }
            if (PersonalInfoField.tag==101)
            {
                PersonalInfoField.text=ID;
            }
            if (PersonalInfoField.tag==102)
            {
                PersonalInfoField.text=Email;
            }
            if (PersonalInfoField.tag==103)
            {
                PersonalInfoField.text=Phonenumber;
            }
            if (PersonalInfoField.tag==104)
            {
                PersonalInfoField.text=Birthday;
            }
            if (PersonalInfoField.tag==105)
            {
                PersonalInfoField.text=Address;
            }
            if (PersonalInfoField.tag==106)
            {
                PersonalInfoField.text=City;
            }
            if (PersonalInfoField.tag==107)
            {
                PersonalInfoField.text=City;
            }
            if (PersonalInfoField.tag==108)
            {
                PersonalInfoField.text=Country;
            }
            if (PersonalInfoField.tag==109)
            {
                PersonalInfoField.text=Zipcode;
            }
            
            [PersonalInfoField addTarget:self action:@selector(personalinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [PersonalInfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [PersonalInfoView addSubview:PersonalInfoField];
            
            d=d+60;
            
        }
        
        @autoreleasepool {
            SavePersonalInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavePersonalInfoBtn.frame=CGRectMake(fieldwidth-100, 720, 80, 30);
            [SavePersonalInfoBtn addTarget:self action:@selector(SavePersonalInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavePersonalInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavePersonalInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [PersonalInfoView addSubview:SavePersonalInfoBtn];
            
            CancelPersonalInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelPersonalInfoBtn.frame=CGRectMake(fieldwidth+20, 720, 80, 30);
            [CancelPersonalInfoBtn addTarget:self action:@selector(CancelpersonalInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelPersonalInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelPersonalInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [PersonalInfoView addSubview:CancelPersonalInfoBtn];
        }
     
    }else if (selectedBtn==103){
        SeleCtedStoreIdsArray=BdStoreidsArray;
        SelectedStoredataArray=DBstorenamesArray;
    
        StoresPopupView=[[UIView alloc]init];
        if (isLandScope) {
            StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [StoresPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:StoresPopupView];
        
        StoresView=[[UIView alloc] init];
        if (isLandScope) {
            StoresView.frame=CGRectMake(100, 50, StoresPopupView.frame.size.width-200, StoresPopupView.frame.size.height-150);
        }
        else
        {
            StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
        }
        
        
        [StoresView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [StoresView.layer setBorderWidth:2.0];
        [StoresView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [StoresPopupView addSubview:StoresView];
        
        StoreDataArray=[[NSMutableArray alloc]init];
        StoreIdsArray=[[NSMutableArray alloc]init];
        NSString *querySQL5 = [NSString stringWithFormat: @"SELECT store_id,store_name FROM store_details"];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:storesArray];
       
        for (NSDictionary *myDict in storesArray)
        {
            [StoreDataArray addObject:[myDict objectForKey:@"store_id"]];
            [StoreIdsArray addObject:[myDict objectForKey:@"store_name"]];
        }
        
        CGFloat widthfield4=(StoresView.frame.size.width)/4;
        StoresTextlbl=[[UILabel alloc] init];
        StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
        [StoresTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [StoresTextlbl setBackgroundColor:[UIColor clearColor]];
        [StoresTextlbl setTextColor:[UIColor whiteColor]];
        [StoresTextlbl setText:@"Store Details"];
        [StoresTextlbl setTextAlignment:NSTextAlignmentLeft];
        [StoresView addSubview:StoresTextlbl];
        
        
        Storeslbl=[[UILabel alloc] init];
        Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
        [Storeslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Storeslbl setBackgroundColor:[UIColor clearColor]];
        [Storeslbl setTextColor:[UIColor whiteColor]];
        
        [Storeslbl setText:@"Add Store"];
        Storeslbl.lineBreakMode = NSLineBreakByWordWrapping;
        Storeslbl.numberOfLines = 2;
        [Storeslbl setTextAlignment:NSTextAlignmentLeft];
        [StoresView addSubview:Storeslbl];
        
        StoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
        [StoresBtn addTarget:self action:@selector(AddstoreClicked) forControlEvents:UIControlEventTouchUpInside];
        [StoresBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [StoresBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [StoresView addSubview:StoresBtn];
        
        
        StoresListTable = [[UITableView alloc] initWithFrame:CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100) style:UITableViewStylePlain];
        StoresListTable.backgroundColor=[UIColor whiteColor];
        StoresListTable.delegate = self;
        StoresListTable.dataSource = self;
        StoresListTable.scrollEnabled = YES;
        StoresListTable.hidden=YES;
        [StoresListTable.layer setBorderWidth: 1.0];
        [StoresListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [StoresView addSubview:StoresListTable];
        
        
        
        StoresDataTable = [[UITableView alloc] initWithFrame:CGRectMake(50, 200,StoresView.frame.size.width-100, 300) style:UITableViewStylePlain];
        StoresDataTable.backgroundColor=[UIColor whiteColor];
        StoresDataTable.delegate = self;
        StoresDataTable.dataSource = self;
        StoresDataTable.scrollEnabled = YES;
        
        [StoresDataTable.layer setBorderWidth: 1.0];
        [StoresDataTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [StoresView addSubview:StoresDataTable];
        @autoreleasepool {
            SavestoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
            [SavestoresBtn addTarget:self action:@selector(SaveStoreInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavestoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavestoresBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [StoresView addSubview:SavestoresBtn];
            
            CancelStoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
            [CancelStoresBtn addTarget:self action:@selector(CancelStoreInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelStoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelStoresBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [StoresView addSubview:CancelStoresBtn];

        }
        
    }

    
}
-(void)SaveEditEmployeeData
{
    
    Exempt=[NSString stringWithFormat:@"%@",ExemptBtn.titleLabel.text];
    Filling=[NSString stringWithFormat:@"%@",FillingBtn.titleLabel.text];
    NSString *password=nil;
    password=[[NSString alloc]init];
    if ([EditPasswordField.text  length]>0){
         password=[password encodeString:EditPasswordField.text];
    }else{
         password=EmpPassword;
    }
    
    NSString *dept=[NSString stringWithFormat:@"%@",EditDepartmentBtn.titleLabel.text];
    
    NSString *EmployeeUpdatestr=@"UPDATE employee_table SET employee_department=?,employee_password=?,employee_display_name=?,employee_card_swipeid=?,employee_customer=?,employee_hourly_wage=?,employee_disable=?,employee_cc_tips=?,employee_admin_card=? WHERE employee_employee_id=?";
   // //NSLog(@"%@",EmployeeUpdatestr);
    NSMutableArray *empupdateArray=[[NSMutableArray alloc]initWithObjects:dept,password,EditDisplaynameField.text,EditCardSwipeIdField.text,EditCustomerField.text,EditHoulrywageField.text,Disable,Cctips,administrative,EditEmployeeIdField.text,nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:EmployeeUpdatestr withArguments:empupdateArray];
    
 
    
    NSString *permissionsUpdatestr=@"UPDATE employee_permissions SET emp_inventory=?,emp_customers=?,emp_reports=?,emp_discounts=?,emp_settings=?,emp_price_hanges=?,emp_allow_exit=?,emp_vendor_payouts=?,emp_delete_items=?,emp_void_invoices=?,emp_transactions=?,emp_holdprint=?,emp_creditcards=?,emp_endcash=? WHERE employee_employee_id=?";
    
    NSMutableArray *empperArray=[[NSMutableArray alloc]initWithObjects:inventory,customers,reports,invoicediscounts,settings,pricechnages,allowexit,payouts,deleteitems,voidinvoices,endTransactions,hold,forceCreditcard,endcash,EditEmployeeIdField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:permissionsUpdatestr withArguments:empperArray];
    
   NSString *PersonalUpdatestr=@"UPDATE employee_personal SET emp_name=?,emp_id=?,emp_email=?,emp_phone=?,emp_birth=?,emp_address=?,emp_city=?,emp_country=?,emp_state=?,emp_postal=? WHERE employee_employee_id=?";
    
    NSMutableArray *emppersonalArry=[[NSMutableArray alloc]initWithObjects:Name,ID,Email,Phonenumber,Birthday,Address,City,Country,state,Zipcode,EditEmployeeIdField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:PersonalUpdatestr withArguments:emppersonalArry];
    
    
    NSString *payrollUpdatestr=@"UPDATE employee_payroll SET federal=?,amount=?,statea=?,stateAmount=?,credits=?,filingstatus=?,exempt=?,excludeCheck=? WHERE employee_employee_id=?";
    
    NSMutableArray *paysArray=[[NSMutableArray alloc]initWithObjects:federal,federalAmount,stateallowances,stateAmount,credits,Filling,Exempt,Exclude,EditEmployeeIdField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:payrollUpdatestr withArguments:paysArray];
   
    
//Employee Data
    
    
    NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password,server_local FROM employee_table WHERE employee_employee_id='%@'",EditEmployeeIdField.text];
    
    NSMutableArray *employeesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesArray];
    
    NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
    [CategoryDict setObject:employeesArray forKey:@"fields"];
    NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
    
    
    NSError *err;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
    
    NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
      
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"employee_table",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
       // // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
       // // //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        //// //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        EConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [EConnection start];
        }
    }
    
//Permissions Data
  
    
    NSString *querySQL2 = [NSString stringWithFormat: @"SELECT emp_inventory,emp_customers,emp_reports,emp_discounts,emp_settings,emp_price_hanges,emp_allow_exit,emp_vendor_payouts,emp_delete_items,emp_void_invoices,emp_transactions,emp_holdprint,emp_creditcards,emp_endcash,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_permissions WHERE employee_employee_id='%@'",EditEmployeeIdField.text];
    NSMutableArray *permissionsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:permissionsArray];
    
    NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
    [CategoryDict2 setObject:permissionsArray forKey:@"fields"];
    NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
    
    
    NSError *err2;
    
    NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
    
    NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str2,@"employee_permissions",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
       // // //NSLog(@"%@",str2);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_permissions&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
       // // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        PermissionsConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [PermissionsConnection start];
        }
    }
//Personal Data
    

    NSString *personalquerySQL = [NSString stringWithFormat: @"SELECT emp_name,emp_id,emp_email,emp_phone,emp_birth,emp_address,emp_city,emp_country,emp_state,emp_postal,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_personal WHERE employee_employee_id='%@'",EditEmployeeIdField.text];
    NSMutableArray *personalsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:personalquerySQL resultsArray:personalsArray];
    
    NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
    [CategoryDict3 setObject:personalsArray forKey:@"fields"];
    NSDictionary *jsonDict3 = [NSDictionary dictionaryWithDictionary:CategoryDict3];
    
    
    NSError *err3;
    
    NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
    
    NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
     
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str3,@"employee_personal",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
       // // //NSLog(@"%@",str3);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_personal&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        //// //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        PersonalConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [PersonalConnection start];
        }
    }
    
    
//Payrolls Data
    

    NSString *payrollquerySQL = [NSString stringWithFormat:@"SELECT federal,amount,statea,stateAmount,credits,filingstatus,exempt,excludeCheck,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_payroll WHERE employee_employee_id='%@'",EditEmployeeIdField.text];
    NSMutableArray *payrollsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:payrollquerySQL resultsArray:payrollsArray];
    
    NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
    [CategoryDict4 setObject:payrollsArray forKey:@"fields"];
    NSDictionary *jsonDict4 = [NSDictionary dictionaryWithDictionary:CategoryDict4];
    
    
    NSError *err4;
    
    NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
    
    NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
      
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str4,@"employee_payroll",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
       // // //NSLog(@"%@",str4);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_payroll&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        //// //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        PayrollConnections = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [PayrollConnections start];
        }
    }


//Store Data
    
   
    NSString *storequerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM employee_store WHERE employee_employee_id='%@'",EditEmployeeIdField.text];
    NSMutableArray *storesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:storequerySQL resultsArray:storesArray];
    NSMutableArray *emplyeeuniqueidsArray=[[NSMutableArray alloc]init];
    for (NSDictionary *Dict in storesArray) {
        
        [emplyeeuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
    }
    NSError *err6;
    
    NSData *jsonData6 = [NSJSONSerialization dataWithJSONObject:emplyeeuniqueidsArray options:kNilOptions error:&err6];
    
    NSString *str6=[[NSString alloc] initWithData:jsonData6 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str6,@"employee_store",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
       // // //NSLog(@"%@",str6);
        NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=employee_store&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str6 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
       // // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [StoreConnection start];
        }
    }
    
      NSString *updateSQL5 = [NSString stringWithFormat: @"DELETE FROM employee_store WHERE employee_employee_id=?"];
    NSMutableArray *deleteArray=[[NSMutableArray alloc]initWithObjects:EditEmployeeIdField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL5 withArguments:deleteArray];
    
    
    NSString *insertSQL;
    
    if ([SelectedStoredataArray count]>0)
    {
        for (int i=0; i<[SelectedStoredataArray count]; i++)
        {
            NSString *storename=[SelectedStoredataArray objectAtIndex:i];
            NSString *storeId=[SeleCtedStoreIdsArray objectAtIndex:i];
            
            insertSQL=@"insert into employee_store (emp_store_name,emp_store_id,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?)";
            NSMutableArray *storeArray=[[NSMutableArray alloc]initWithObjects:storename,storeId,EditEmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:storeArray];
        
            
            
        }
    }
    
    NSString *storequerySQL2 = [NSString stringWithFormat:@"SELECT emp_store_name,emp_store_id,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_store WHERE employee_employee_id='%@'",EditEmployeeIdField.text];
    NSMutableArray *storesArray2=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:storequerySQL2 resultsArray:storesArray2];
    
    NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
    [CategoryDict5 setObject:storesArray2 forKey:@"fields"];
    NSDictionary *jsonDict5 = [NSDictionary dictionaryWithDictionary:CategoryDict5];
    
    
    NSError *err5;
    
    NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
    
    NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"employee_store",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
        //// //NSLog(@"%@",str5);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_store&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
       // // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [StoreConnection start];
        }
    
    }
    
     SelectedStoredataArray=nil;SeleCtedStoreIdsArray=nil;
    
    
    Name=@"";
    ID=@"";
    Email=@"";
    Phonenumber=@"";
    Birthday=@"";
    Address=@"";
    City=@"";
    Country=@"";
    state=@"";
    Zipcode=@"";
    
    inventory=@"";reports=@"";settings=@"";allowexit=@"";deleteitems=@"";endTransactions=@"";forceCreditcard=@"";
    customers=@"";invoicediscounts=@"";pricechnages=@"";payouts=@"";voidinvoices=@"";hold=@"";endcash=@"";
    Exclude=@"";federal=@"";federalAmount=@"";stateallowances=@"";stateAmount=@"";credits=@"";
    Exempt=@"";Filling=@"";
    
    Disable=@"";administrative=@"";Cctips=@"";

    NSString *empquerySQL = [NSString stringWithFormat: @"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password FROM employee_table"];
    NSMutableArray *editemployeesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:empquerySQL resultsArray:editemployeesArray];
    
    NSMutableArray *rdarray=editemployeesArray;
    
    //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [employeepaginationObject   setCompleteresultset:rdarray];
    
    [employeepaginationObject    paginationinitializer:rdarray :20];
    
    [employeepaginationObject   paginationsegment].tintColor=[UIColor whiteColor];
    [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
    
    [[employeepaginationObject   paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [employeepaginationObject   paginationsegment].selectedSegmentIndex=selectedsegindex;
   [employeepaginationObject   activateResults:selectedsegindex];
    [EmployeesBackView addSubview:[employeepaginationObject   paginationsegment]];
    NSArray *EditemployeeViewArray = EditemployeeView.subviews;
    for (int i = 0; i<[EditemployeeViewArray count]; i++) {
        UIView *vi =[EditemployeeViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditEmployeePopUpArray = EditEmployeePopUp.subviews;
    for (int i = 0; i<[EditEmployeePopUpArray count]; i++) {
        UIView *vi =[EditEmployeePopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditemployeeView removeFromSuperview],[EditEmployeePopUp removeFromSuperview];
    
    [EmDepartmentsArray removeAllObjects];
    [EmployeeIdsArray removeAllObjects];
    [passwordsArray removeAllObjects];
    [DisplayNamesArray removeAllObjects];
    
    [cardswipeidsArray removeAllObjects];
    [EmCustomersArray removeAllObjects];
    [houlrywagesArray removeAllObjects];
    
    [disablesArray removeAllObjects];
    [administativesArray removeAllObjects];
    [CctipsArray removeAllObjects];
    
    [NamesArray removeAllObjects];
    [IDsArray removeAllObjects];
    [EmailsArray removeAllObjects];
    [PhonenumbersArray removeAllObjects];
    
    [BirthdaysArray removeAllObjects];
    [AddresssArray removeAllObjects];
    [CitysArray removeAllObjects];
    
    [CountrysArray removeAllObjects];
    [statesArray removeAllObjects];
    [ZipcodesArray removeAllObjects];
    
    [inventorysArray removeAllObjects];
    [reportssArray removeAllObjects];
    [settingssArray removeAllObjects];
    [allowexitsArray removeAllObjects];
    
    [deleteitemssArray removeAllObjects];
    [endTransactionssArray removeAllObjects];
    [forceCreditcardsArray removeAllObjects];
    
    [customerssArray removeAllObjects];
    [invoicediscountssArray removeAllObjects];
    [pricechnagessArray removeAllObjects];
    
    [payoutssArray removeAllObjects];
    [voidinvoicessArray removeAllObjects];
    [holdsArray removeAllObjects];
    [endcashsArray removeAllObjects];
    
    EmDepartmentsArray=nil;
    EmployeeIdsArray=nil;
    passwordsArray=nil;
    DisplayNamesArray=nil;
    
    cardswipeidsArray=nil;
    EmCustomersArray=nil;
    houlrywagesArray=nil;
    
    disablesArray=nil;
    administativesArray=nil;
    CctipsArray=nil;
    
    NamesArray=nil;
    IDsArray=nil;
    EmailsArray=nil;
    PhonenumbersArray=nil;
    
    BirthdaysArray=nil;
    AddresssArray=nil;
    CitysArray=nil;
    
    CountrysArray=nil;
    statesArray=nil;
    ZipcodesArray=nil;
    
    inventorysArray=nil;
    reportssArray=nil;
    settingssArray=nil;
    allowexitsArray=nil;
    
    deleteitemssArray=nil;
    endTransactionssArray=nil;
    forceCreditcardsArray=nil;
    
    customerssArray=nil;
    invoicediscountssArray=nil;
    pricechnagessArray=nil;
    
    payoutssArray=nil;
    voidinvoicessArray=nil;
    holdsArray=nil;
    endcashsArray=nil;
     [self GetEmployeeDataMethod];
    [EditEmployeeTable reloadData];

}

-(void)CancelEditEmployeeData
{
    NSArray *EditemployeeViewArray = EditemployeeView.subviews;
    for (int i = 0; i<[EditemployeeViewArray count]; i++) {
        UIView *vi =[EditemployeeViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditEmployeePopUpArray = EditEmployeePopUp.subviews;
    for (int i = 0; i<[EditEmployeePopUpArray count]; i++) {
        UIView *vi =[EditEmployeePopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditemployeeView removeFromSuperview],[EditEmployeePopUp removeFromSuperview];
}
-(void)DuplicateEmployee:(UIButton *)sender
{
  
}
-(void)SaveDuplicateEmployeeData
{
    NSString *dept=[NSString stringWithFormat:@"%@",EditDepartmentBtn.titleLabel.text];
    Exempt=[NSString stringWithFormat:@"%@",ExemptBtn.titleLabel.text];
    Filling=[NSString stringWithFormat:@"%@",FillingBtn.titleLabel.text];
    if (!EmployeeIdsArray)
    EmployeeIdsArray=[[NSMutableArray alloc]init];
    NSString *password=[[NSString alloc]init];
   
    if ([EditPasswordField.text  length]>0)
    {
        password=[password encodeString:EditPasswordField.text];
    }else{
        password=EmpPassword;
    }
    NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_employee_id FROM employee_table"];
    NSMutableArray *empArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:empArray];
    
    @autoreleasepool {
        for (NSDictionary *myDict in empArray)
        {
            NSString *catname=[myDict objectForKey:@"employee_employee_id"];
            
            [EmployeeIdsArray addObject:catname];
            
        }
    }

    NSUInteger objIdx = [EmployeeIdsArray containsObject:DuplicateEmployeeIdField.text];
    //// //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
        NSString *EinsertSql;
        EinsertSql=@"insert into employee_table (employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *empsArray=[[NSMutableArray alloc]initWithObjects:dept,DuplicateEmployeeIdField.text,password,EditDisplaynameField.text,EditCardSwipeIdField.text,EditCustomerField.text,EditHoulrywageField.text,Disable,Cctips,administrative,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],password, nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:EinsertSql withArguments:empsArray];
       
        NSString *PermissionsinsertSql,*PayrollSql,*Personalsql;
        
        PermissionsinsertSql=@"insert into employee_permissions (emp_inventory,emp_customers,emp_reports,emp_discounts,emp_settings,emp_price_hanges,emp_allow_exit,emp_vendor_payouts,emp_delete_items,emp_void_invoices,emp_transactions,emp_holdprint,emp_creditcards,emp_endcash,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *permissionsArray=[[NSMutableArray alloc]initWithObjects:inventory,customers,reports,invoicediscounts,settings,pricechnages,allowexit,payouts,deleteitems,voidinvoices,endTransactions,hold,forceCreditcard,endcash,DuplicateEmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:PermissionsinsertSql withArguments:permissionsArray];
        

        Personalsql=@"insert into employee_personal (emp_name,emp_id,emp_email,emp_phone,emp_birth,emp_address,emp_city,emp_country,emp_state,emp_postal,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *personalsArray=[[NSMutableArray alloc]initWithObjects:Name,ID,Email,Phonenumber,Birthday,Address,City,Country,state,Zipcode,DuplicateEmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
       [[DataBaseManager dataBaseManager]executeRecordsWithQuery:Personalsql withArguments:personalsArray];
        
        
        PayrollSql=@"insert into employee_payroll (federal,amount,statea,stateAmount,credits,filingstatus,exempt,excludeCheck,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values (?,?,?,?,?,?,?,?,?,?,?,?)";
       
        NSMutableArray *payrollsArray=[[NSMutableArray alloc]initWithObjects:federal,federalAmount,stateallowances,stateAmount,credits,Filling,Exempt,Exclude,DuplicateEmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:PayrollSql withArguments:payrollsArray];
        
//Employee Data
     
        
        NSString *querySQL = [NSString stringWithFormat: @"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password,server_local FROM employee_table WHERE employee_employee_id='%@'",DuplicateEmployeeIdField.text];
        
        NSMutableArray *employeesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:employeesArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"employee_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                EConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [EConnection start];
            }
        }
        
//Permissions Data
       
        
        NSString *querySQL2 = [NSString stringWithFormat: @"SELECT emp_inventory,emp_customers,emp_reports,emp_discounts,emp_settings,emp_price_hanges,emp_allow_exit,emp_vendor_payouts,emp_delete_items,emp_void_invoices,emp_transactions,emp_holdprint,emp_creditcards,emp_endcash,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_permissions WHERE employee_employee_id='%@'",DuplicateEmployeeIdField.text];
        NSMutableArray *emppermissionArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:emppermissionArray];
        
        NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
        [CategoryDict2 setObject:emppermissionArray forKey:@"fields"];
        NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
        
        
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str2,@"employee_permissions",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str2);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_permissions&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                PermissionsConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [PermissionsConnection start];
            }
        }
//Personal Data
        

        NSString *personalquerySQL = [NSString stringWithFormat: @"SELECT emp_name,emp_id,emp_email,emp_phone,emp_birth,emp_address,emp_city,emp_country,emp_state,emp_postal,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_personal WHERE employee_employee_id='%@'",DuplicateEmployeeIdField.text];
        NSMutableArray *emppersonalsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:personalquerySQL resultsArray:emppersonalsArray];
        
        NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
        [CategoryDict3 setObject:emppersonalsArray forKey:@"fields"];
        NSDictionary *jsonDict3 = [NSDictionary dictionaryWithDictionary:CategoryDict3];
        
        
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str3,@"employee_personal",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // // //NSLog(@"%@",str3);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_personal&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                //// //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                PersonalConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [PersonalConnection start];
            }
        }
//Payrolls Data
    
        NSString *payrollquerySQL = [NSString stringWithFormat:@"SELECT federal,amount,statea,stateAmount,credits,filingstatus,exempt,excludeCheck,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_payroll WHERE employee_employee_id='%@'",DuplicateEmployeeIdField.text];
        NSMutableArray *emppayrollsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:payrollquerySQL resultsArray:emppayrollsArray];
        
        
        NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
        [CategoryDict4 setObject:emppayrollsArray forKey:@"fields"];
        NSDictionary *jsonDict4 = [NSDictionary dictionaryWithDictionary:CategoryDict4];
        
        
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str4,@"employee_payroll",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str4);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_payroll&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                PayrollConnections = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [PayrollConnections start];
            }
        }
      
//Store Data
        
    
        NSString *insertSQL;
        
        if ([SelectedStoredataArray count]>0)
        {
            for (int i=0; i<[SelectedStoredataArray count]; i++)
            {
                NSString *storename=[SelectedStoredataArray objectAtIndex:i];
                NSString *storeId=[SeleCtedStoreIdsArray objectAtIndex:i];
                
                insertSQL=@"insert into employee_store (emp_store_name,emp_store_id,employee_employee_id,unique_id,created_timestamp,modified_timestamp) values (?,?,?,?,?,?)";
                NSMutableArray *storesArray=[[NSMutableArray alloc]initWithObjects:storename,storeId,EmployeeIdField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
                // //NSLog(@"store data %@",StoreSql);
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:storesArray];
                
                
            }
        }
        
    
        NSString *storequerySQL = [NSString stringWithFormat:@"SELECT emp_store_name,emp_store_id,employee_employee_id,unique_id,created_timestamp,modified_timestamp,server_local FROM employee_store WHERE employee_employee_id='%@'",DuplicateEmployeeIdField.text];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:storequerySQL resultsArray:storesArray];
        
        NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
        [CategoryDict5 setObject:storesArray forKey:@"fields"];
        NSDictionary *jsonDict5 = [NSDictionary dictionaryWithDictionary:CategoryDict5];
        
        
        NSError *err5;
        
        NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
        
        NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"employee_store",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str5);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=employee_store&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [StoreConnection start];
            }
        }
        NSString *empquerySQL = [NSString stringWithFormat:@"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password FROM employee_table"];
        
        NSMutableArray *employeeArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:empquerySQL resultsArray:employeeArray];
        SelectedStoredataArray=nil;SeleCtedStoreIdsArray=nil;
        
        NSMutableArray *rdarray=employeeArray;
        
        //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
        
        [employeepaginationObject   setCompleteresultset:rdarray];
        
        [employeepaginationObject    paginationinitializer:rdarray :20];
        
        [employeepaginationObject   paginationsegment].tintColor=[UIColor whiteColor];
        [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
        
        [[employeepaginationObject   paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [employeepaginationObject   paginationsegment].selectedSegmentIndex=selectedsegindex;
       [employeepaginationObject   activateResults:selectedsegindex];
        [EmployeesBackView addSubview:[employeepaginationObject   paginationsegment]];
        
        NSArray *EditemployeeViewArray = EditemployeeView.subviews;
        for (int i = 0; i<[EditemployeeViewArray count]; i++) {
            UIView *vi =[EditemployeeViewArray objectAtIndex:i];
            [vi removeFromSuperview];
            vi = nil;
        }
        NSArray *EditEmployeePopUpArray = EditEmployeePopUp.subviews;
        for (int i = 0; i<[EditEmployeePopUpArray count]; i++) {
            UIView *vi =[EditEmployeePopUpArray objectAtIndex:i];
            [vi removeFromSuperview];
            vi = nil;
        }
        [EditemployeeView removeFromSuperview],[EditEmployeePopUp removeFromSuperview];
        //[EditEmployeePopUp removeFromSuperview];
       
        
        [EmDepartmentsArray removeAllObjects];
        [EmployeeIdsArray removeAllObjects];
        [passwordsArray removeAllObjects];
        [DisplayNamesArray removeAllObjects];
        
        [cardswipeidsArray removeAllObjects];
        [EmCustomersArray removeAllObjects];
        [houlrywagesArray removeAllObjects];
        
        [disablesArray removeAllObjects];
        [administativesArray removeAllObjects];
        [CctipsArray removeAllObjects];
        
        [NamesArray removeAllObjects];
        [IDsArray removeAllObjects];
        [EmailsArray removeAllObjects];
        [PhonenumbersArray removeAllObjects];
        
        [BirthdaysArray removeAllObjects];
        [AddresssArray removeAllObjects];
        [CitysArray removeAllObjects];
        
        [CountrysArray removeAllObjects];
        [statesArray removeAllObjects];
        [ZipcodesArray removeAllObjects];
        
        [inventorysArray removeAllObjects];
        [reportssArray removeAllObjects];
        [settingssArray removeAllObjects];
        [allowexitsArray removeAllObjects];
        
        [deleteitemssArray removeAllObjects];
        [endTransactionssArray removeAllObjects];
        [forceCreditcardsArray removeAllObjects];
        
        [customerssArray removeAllObjects];
        [invoicediscountssArray removeAllObjects];
        [pricechnagessArray removeAllObjects];
        
        [payoutssArray removeAllObjects];
        [voidinvoicessArray removeAllObjects];
        [holdsArray removeAllObjects];
        [endcashsArray removeAllObjects];
        
        EmDepartmentsArray=nil;
        EmployeeIdsArray=nil;
        passwordsArray=nil;
        DisplayNamesArray=nil;
        
        cardswipeidsArray=nil;
        EmCustomersArray=nil;
        houlrywagesArray=nil;
        
        disablesArray=nil;
        administativesArray=nil;
        CctipsArray=nil;
        
        NamesArray=nil;
        IDsArray=nil;
        EmailsArray=nil;
        PhonenumbersArray=nil;
        
        BirthdaysArray=nil;
        AddresssArray=nil;
        CitysArray=nil;
        
        CountrysArray=nil;
        statesArray=nil;
        ZipcodesArray=nil;
        
        inventorysArray=nil;
        reportssArray=nil;
        settingssArray=nil;
        allowexitsArray=nil;
        
        deleteitemssArray=nil;
        endTransactionssArray=nil;
        forceCreditcardsArray=nil;
        
        customerssArray=nil;
        invoicediscountssArray=nil;
        pricechnagessArray=nil;
        
        payoutssArray=nil;
        voidinvoicessArray=nil;
        holdsArray=nil;
        endcashsArray=nil;
         [self GetEmployeeDataMethod];
        [EditEmployeeTable reloadData];
        
        Name=@"";
        ID=@"";
        Email=@"";
        Phonenumber=@"";
        Birthday=@"";
        Address=@"";
        City=@"";
        Country=@"";
        state=@"";
        Zipcode=@"";
        inventory=@"";reports=@"";settings=@"";allowexit=@"";deleteitems=@"";endTransactions=@"";forceCreditcard=@"";
        customers=@"";invoicediscounts=@"";pricechnages=@"";payouts=@"";voidinvoices=@"";hold=@"";endcash=@"";
        Exclude=@"";federal=@"";federalAmount=@"";stateallowances=@"";stateAmount=@"";credits=@"";
        Exempt=@"";Filling=@"";
        
        Disable=@"";administrative=@"";Cctips=@"";
       
        
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Employee Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Employee ID already exist change the Employee ID" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
    }

}
-(void)deleteEmployee:(UIButton *)sender
{
   
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
{
    if (alertView==DeleteEmployeeAlert && buttonIndex==0)
    {
        
        NSString *selectedid=[EmployeeIdsArray objectAtIndex:SelectedEmployee];
        //NSLog(@"%@",selectedid);
       
        
//Employee Data
        NSString *querySQL = [NSString stringWithFormat:@"SELECT unique_id FROM employee_table WHERE employee_employee_id='%@'",selectedid];
        
        NSMutableArray *employeesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:employeesArray];
        NSMutableArray *emplyeeuniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in employeesArray) {
            
            [emplyeeuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:emplyeeuniqueidsArray options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str,@"employee_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=employee_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            EConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [EConnection start];
            }
        }
        
//Permissions Data
       
        NSString *querySQL2 = [NSString stringWithFormat: @"SELECT unique_id FROM employee_permissions WHERE employee_employee_id='%@'",selectedid];
        NSMutableArray *permissionsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:permissionsArray];
    
        NSMutableArray *permissionsuniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in permissionsArray) {
            
            [permissionsuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:permissionsuniqueidsArray options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str2,@"employee_permissions",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        }
        else if([generalDataObject  connectedToInternet]){
            
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=employee_permissions&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            PermissionsConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [PermissionsConnection start];
            }
        }
        
//Personal Data
        
        NSString *personalquerySQL = [NSString stringWithFormat: @"SELECT unique_id FROM employee_personal WHERE employee_employee_id='%@'",selectedid];
        NSMutableArray *personalsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:personalquerySQL resultsArray:personalsArray];
        
        NSMutableArray *personaluniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in personalsArray) {
            
            [personaluniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:personaluniqueidsArray options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
           
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str3,@"employee_personal",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=employee_personal&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            PersonalConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [PersonalConnection start];
            }
        }
        
        
//Payrolls Data
        
    
        NSString *payrollquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM employee_payroll WHERE employee_employee_id='%@'",selectedid];
        NSMutableArray *payrollsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:payrollquerySQL resultsArray:payrollsArray];
        
        NSMutableArray *payrolluniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in payrollsArray) {
            
            [payrolluniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:payrolluniqueidsArray options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
    
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str4,@"employee_payroll",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=employee_payroll&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            PayrollConnections = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [PayrollConnections start];
            }
        }

 //stores data
        NSString *storequerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM employee_store WHERE employee_employee_id='%@'",selectedid];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:storequerySQL resultsArray:storesArray];
        
        NSMutableArray *storeuniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in storesArray) {
            
            [storeuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        
        NSError *err6;
        
        NSData *jsonData6 = [NSJSONSerialization dataWithJSONObject:storeuniqueidsArray options:kNilOptions error:&err6];
        
        NSString *str6=[[NSString alloc] initWithData:jsonData6 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
        
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str6,@"employee_store",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str6);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=employee_store&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str6 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [StoreConnection start];
            }
        }
        NSMutableArray *deleteArray;
        
        NSString *updateSQL = [NSString stringWithFormat: @"DELETE FROM employee_table WHERE employee_employee_id='%@'",selectedid];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:deleteArray];
        
          NSString *updateSQL2 = [NSString stringWithFormat: @"DELETE FROM employee_personal WHERE employee_employee_id='%@'",selectedid];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL2 withArguments:deleteArray];
        
           NSString *updateSQL3 = [NSString stringWithFormat: @"DELETE FROM employee_payroll WHERE employee_employee_id='%@'",selectedid];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL3 withArguments:deleteArray];
         NSString *updateSQL5 = [NSString stringWithFormat: @"DELETE FROM employee_store WHERE employee_employee_id='%@'",selectedid];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL5 withArguments:deleteArray];
        
       
        
        NSString *empquerySQL = [NSString stringWithFormat:@"SELECT employee_department,employee_employee_id,employee_password,employee_display_name,employee_card_swipeid,employee_customer,employee_hourly_wage,employee_disable,employee_cc_tips,employee_admin_card,unique_id,created_timestamp,modified_timestamp,server_password FROM employee_table"];
        NSMutableArray *editemployeesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:empquerySQL resultsArray:editemployeesArray];

        NSMutableArray *rdarray=editemployeesArray;
        
       // NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
        
        [employeepaginationObject   setCompleteresultset:rdarray];
        
        [employeepaginationObject    paginationinitializer:rdarray :20];
        
        [employeepaginationObject   paginationsegment].tintColor=[UIColor whiteColor];
        [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
        
        [[employeepaginationObject   paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [employeepaginationObject   paginationsegment].selectedSegmentIndex=selectedsegindex;
       [employeepaginationObject   activateResults:selectedsegindex];
        
        [EmployeesBackView addSubview:[employeepaginationObject   paginationsegment]];
    
        [EmDepartmentsArray removeAllObjects];
        [EmployeeIdsArray removeAllObjects];
        [passwordsArray removeAllObjects];
        [DisplayNamesArray removeAllObjects];
        
        [cardswipeidsArray removeAllObjects];
        [EmCustomersArray removeAllObjects];
        [houlrywagesArray removeAllObjects];
        
        [disablesArray removeAllObjects];
        [administativesArray removeAllObjects];
        [CctipsArray removeAllObjects];
        
        [NamesArray removeAllObjects];
        [IDsArray removeAllObjects];
        [EmailsArray removeAllObjects];
        [PhonenumbersArray removeAllObjects];
        
        [BirthdaysArray removeAllObjects];
        [AddresssArray removeAllObjects];
        [CitysArray removeAllObjects];
        
        [CountrysArray removeAllObjects];
        [statesArray removeAllObjects];
        [ZipcodesArray removeAllObjects];
        
        [inventorysArray removeAllObjects];
        [reportssArray removeAllObjects];
        [settingssArray removeAllObjects];
        [allowexitsArray removeAllObjects];
        
        [deleteitemssArray removeAllObjects];
        [endTransactionssArray removeAllObjects];
        [forceCreditcardsArray removeAllObjects];
        
        [customerssArray removeAllObjects];
        [invoicediscountssArray removeAllObjects];
        [pricechnagessArray removeAllObjects];
        
        [payoutssArray removeAllObjects];
        [voidinvoicessArray removeAllObjects];
        [holdsArray removeAllObjects];
        [endcashsArray removeAllObjects];
        
        EmDepartmentsArray=nil;
        EmployeeIdsArray=nil;
        passwordsArray=nil;
        DisplayNamesArray=nil;
        
        cardswipeidsArray=nil;
        EmCustomersArray=nil;
        houlrywagesArray=nil;
        
        disablesArray=nil;
        administativesArray=nil;
        CctipsArray=nil;
        
        NamesArray=nil;
        IDsArray=nil;
        EmailsArray=nil;
        PhonenumbersArray=nil;
        
        BirthdaysArray=nil;
        AddresssArray=nil;
        CitysArray=nil;
        
        CountrysArray=nil;
        statesArray=nil;
        ZipcodesArray=nil;
        
        inventorysArray=nil;
        reportssArray=nil;
        settingssArray=nil;
        allowexitsArray=nil;
        
        deleteitemssArray=nil;
        endTransactionssArray=nil;
        forceCreditcardsArray=nil;
        
        customerssArray=nil;
        invoicediscountssArray=nil;
        pricechnagessArray=nil;
        
        payoutssArray=nil;
        voidinvoicessArray=nil;
        holdsArray=nil;
        endcashsArray=nil;
         [self GetEmployeeDataMethod];
        [EditEmployeeTable reloadData];
        
    }
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    
    if (connection == EConnection){
        EResponseData = [[NSMutableData alloc] init];
    }else if (connection == PermissionsConnection){
        PermissionsResponseData = [[NSMutableData alloc] init];
    }else if (connection == PersonalConnection){
        PersonalResponseData = [[NSMutableData alloc] init];
    }else if (connection == PayrollConnections){
        PayrollResponseData = [[NSMutableData alloc] init];
    }else if (connection == StoreConnection){
        StoreResponseData = [[NSMutableData alloc] init];
    }
    
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    
    if (connection == EConnection){
        [EResponseData appendData:data];
    }else if (connection == PermissionsConnection){
        [PermissionsResponseData appendData:data];
    }else if (connection == PersonalConnection){
        [PersonalResponseData appendData:data];
        
    }else if (connection == PayrollConnections){
        [PayrollResponseData appendData:data];
        
    }else if (connection == StoreConnection){
        [StoreResponseData appendData:data];
    }
   
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    if (connection == EConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[EResponseData mutableBytes] length:[EResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
      dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        
        // //NSLog(@"%@",dataDict);
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
     
        
    }else if (connection == PermissionsConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[PermissionsResponseData mutableBytes] length:[PermissionsResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
        
    }else if (connection == PersonalConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[PersonalResponseData mutableBytes] length:[PersonalResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
       
        
    }else if (connection == PayrollConnections){
        NSString *responseStr = [[NSString alloc] initWithBytes:[PayrollResponseData mutableBytes] length:[PayrollResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
        
    }else if (connection == StoreConnection){
       
        NSString *responseStr = [[NSString alloc] initWithBytes:[StoreResponseData mutableBytes] length:[StoreResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
    }
}
-(void)segmentchanged4:(UISegmentedControl *)sender
{
    // //NSLog(@"active results %@ ",[[pagination sharedInstance]activeresultset]);
    
    [employeepaginationObject   activateResults:[employeepaginationObject  paginationsegment].selectedSegmentIndex];
    [self GetEmployeeDataMethod];
    [EditEmployeeTable reloadData];
}
-(void)updateUI
{
    
    if (isLandScope)
    {
        
        CGFloat width,height;
        
        width=1024;
        height=748;
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        
        
        //  sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
        //sidemenu.hidden=YES;
        
        [categorybutton setFrame:CGRectMake(0.0,p,170,40)];
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        
        // mainview.frame=CGRectMake(sidemenu.frame.size.width+10,0,width-(sidemenu.frame.size.width+20),height-150);
        mainview.frame=CGRectMake(20,60,width-40,height-200);
        
        [backgroundcolorview addSubview:mainview];
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
  
 //employee view
        
        EmployeesBackView.frame=CGRectMake(10, 0, mainview.frame.size.width-20, (mainview.frame.size.height));
       
        CGFloat addbuttonwidth=(EmployeesBackView.frame.size.width-10)/2;
        AddEmployeeBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
       
        EditEmployeeBtn.frame=CGRectMake(AddEmployeeBtn.frame.size.width, 10, addbuttonwidth, 40);
      
        
        AddEmployeesView.frame=CGRectMake(10, AddEmployeeBtn.frame.size.height+10, EmployeesBackView.frame.size.width-20, EmployeesBackView.frame.size.height-20-AddEmployeeBtn.frame.size.height);
        AddEmployeesView.contentSize=CGSizeMake(EmployeesBackView.frame.size.width-20,  EmployeesBackView.frame.size.height+100);
      
        CGFloat customerW=(AddEmployeesView.frame.size.width)/4;
        CGFloat r=(customerW/2)+20;
        
      
        Departmentlbl.frame=CGRectMake(r-90, 30,customerW, 50);
        
        DepartmentBtn.frame=CGRectMake(customerW-5, 35,customerW, 40);
       
        
        DepartmentListTable.frame =CGRectMake(customerW-5, 75,customerW, 100);
       
        EmployeeIdLbl.frame=CGRectMake(r-90, 90,customerW, 50);
        
      
        EmployeeIdField.frame=CGRectMake(customerW-5, 95,customerW, 40);
       
        Passwordlbl.frame=CGRectMake(r-90, 150,customerW, 50);
        
     
        PasswordField.frame=CGRectMake(customerW-5, 155,customerW, 40);
        
        Displaynamelbl.frame=CGRectMake(r-90, 210,customerW, 50);
        
       
        DisplaynameField.frame=CGRectMake(customerW-5, 215,customerW, 40);
      
        CardSwipeIdlbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 30,customerW, 50);
        
     
        CardSwipeIdField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 35,customerW, 40);
     
        CustomerLbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 90,customerW, 50);
       
        CustomerField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 95,customerW, 40);
      
        Houlrywagelbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 150,customerW, 50);
      
        HoulrywageField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 155,customerW, 40);
      
        Disablelbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 210,customerW+80, 50);
      
        
        disableBtn.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+Disablelbl.frame.size.width, 220,30, 30);
     
        administrativelbl.frame=CGRectMake(r-90, 270,customerW+100, 50);
        
        administrativeBtn.frame=CGRectMake(r-80+administrativelbl.frame.size.width, 280,30, 30);
       
        TakeccTipslbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 250,customerW+80, 100);
        
        TakeccTipsBtn.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+TakeccTipslbl.frame.size.width+20, 280,30, 30);
        
        CGFloat wdth=(AddEmployeesView.frame.size.width)/5;
        CGFloat xvalue=wdth/4;
        for (int k=0; k<4; k++)
        {
            UIButton *mybtn=(UIButton *)[AddEmployeesView viewWithTag:k+100];
            mybtn.frame=CGRectMake(xvalue,340,wdth+5, 40);
            [AddEmployeesView addSubview:mybtn];
            
               xvalue=xvalue+wdth+15;
            
        }
      
        SaveEmployeeBtn.frame=CGRectMake(customerW+100, 420, 80, 30);
        CancelEmployeeBtn.frame=CGRectMake(customerW+220, 420, 80, 30);
        
        [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
        
       
        EditEmployeeTable.frame=CGRectMake(10, AddEmployeeBtn.frame.size.height+50, EmployeesBackView.frame.size.width-20, EmployeesBackView.frame.size.height-20-AddEmployeeBtn.frame.size.height-40);
        
//Personal Info View
        
        PersonalInfoPopupView.frame=CGRectMake(0, 0, 1024, 768);
   
    PersonalInfoView.frame=CGRectMake(75, 50, PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height-100);
    PersonalInfoView.contentSize=CGSizeMake(PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height+200);
   
    
    CGFloat fieldwidth=(PersonalInfoView.frame.size.width)/2;
    
    CGFloat o=(fieldwidth/2);
   
    PersonalInfotextlbl.frame=CGRectMake(fieldwidth-110, 10,fieldwidth+100, 40);
    
    int d=70;
    
    for (int i=0; i<10; i++)
    {
        
        UILabel *mylabel=(UILabel *)[PersonalInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
        [PersonalInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[PersonalInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(mylabel.frame.size.width-20, d,fieldwidth-80, 40);
        [PersonalInfoView addSubview:mytextfield];
        
        d=d+60;
        
    }
    SavePersonalInfoBtn.frame=CGRectMake(fieldwidth-100, 720, 80, 30);
    CancelPersonalInfoBtn.frame=CGRectMake(fieldwidth+20, 720, 80, 30);
    
 //Payroll View
        
    PayrollPopUpView.frame=CGRectMake(0, 0, 1024, 768);
   
    PayrollView.frame=CGRectMake(25, 50, PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height-100);
    PayrollView.contentSize=CGSizeMake(PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height+200);

    CGFloat payrollwidth=(PayrollView.frame.size.width)/2;
    CGFloat pay=(payrollwidth/2);
    
   
    PayrollTextLbl.frame=CGRectMake(payrollwidth-80, 10,payrollwidth+100, 40);
    Excludelbl.frame=CGRectMake(pay-160, 60,payrollwidth+80, 40);
    
    ExcludeBtn.frame=CGRectMake(Excludelbl.frame.size.width-150, 65,30, 30);
    
    int k=100;
    
    for (int i=0; i<5; i++)
    {
        UILabel *mylabel=(UILabel *)[PayrollView viewWithTag:i+100];
        mylabel.frame=CGRectMake(pay-175, k,payrollwidth+80, 40);
        [PayrollView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[PayrollView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(mylabel.frame.size.width-10, k,payrollwidth-80, 40);
        [PayrollView addSubview:mytextfield];
        
        k=k+60;
        
    }
   
    Exemptlbl.frame=CGRectMake(pay-175, 400,payrollwidth+80, 40);
    ExemptBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 400,payrollwidth-80, 40);
    ExemptsTable.frame=CGRectMake(Exemptlbl.frame.size.width-5, 440,payrollwidth-80, 100);
    FillingStatuslbl.frame=CGRectMake(pay-175, 460,payrollwidth+80, 40);
    FillingBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 460,payrollwidth-80, 40);
    FillingsTable.frame =CGRectMake(Exemptlbl.frame.size.width-5, 500,payrollwidth-80, 100);
    
    SavePayrollBtn.frame=CGRectMake(payrollwidth-100, 620, 80, 30);
    CancelPayrollBtn.frame=CGRectMake(payrollwidth+20, 620, 80, 30);
    
        
//Permissions View
        
    PermissionsPopupView.frame=CGRectMake(0, 0, 1024, 768);
   
  PermissionsView.frame=CGRectMake(25, 50, PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height-100);
    PermissionsView.contentSize=CGSizeMake(PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height+200);
  
    
    CGFloat permissionwidth=(PermissionsView.frame.size.width)/4;
    CGFloat perm=(permissionwidth/2);
    
    PermissonsTextlbl.frame=CGRectMake(permissionwidth+100, 10,permissionwidth+100, 40);
    
    int s=100;
    
    for (int i=0; i<7; i++)
    {
        
        UILabel *mylabel=(UILabel *)[PermissionsView viewWithTag:i+100];
        mylabel.frame=CGRectMake(perm-60, s,permissionwidth+80, 40);
        [PermissionsView addSubview:mylabel];
        
        UISwitch *myswitch=(UISwitch *)[PermissionsView viewWithTag:i+100];
        myswitch.frame=CGRectMake(mylabel.frame.size.width+10, s+5,permissionwidth, 40);
        [PermissionsView addSubview:myswitch];
        
        s=s+60;
        
    }
    int m=100;
    
    for (int i=0; i<7; i++)
    {
        
        UILabel *mylabel=(UILabel *)[PermissionsView viewWithTag:i+100];
        mylabel.frame=CGRectMake(perm+PermissionLbl.frame.size.width, m,permissionwidth+80, 40);
        [PermissionsView addSubview:mylabel];
        
        UISwitch *myswitch=(UISwitch *)[PermissionsView viewWithTag:i+100];
        myswitch.frame=CGRectMake(perm+PermissionLbl.frame.size.width-30+mylabel.frame.size.width+40, m+5,permissionwidth, 40);
        [PermissionsView addSubview:myswitch];
        
        m=m+60;
        
    }
    
    SavePermissionBtn.frame=CGRectMake(permissionwidth+100, 580, 80, 30);
    CancelPermissionsBtn.frame=CGRectMake(permissionwidth+220, 580, 80, 30);
        
 //Edit Employee View
        
        EditEmployeePopUp.frame=CGRectMake(0, 0, 1024, 768);
   
    EditemployeeView.frame=CGRectMake(20, 100, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-200);
   

       // EditemployeeView.frame=CGRectMake(20, 200, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-500);
    
    EditemployeeView.contentSize=CGSizeMake(EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height+100);
    

    CGFloat Employee=(EditemployeeView.frame.size.width)/4;
    CGFloat E=(Employee/2)+20;
    
   
    EditDepartmentlbl.frame=CGRectMake(E-90, 30,Employee, 50);
    
    EditDepartmentBtn.frame=CGRectMake(Employee-5, 35,Employee, 40);
    
    EditDepartmentListTable.frame = CGRectMake(Employee-5, 75,Employee, 100);
   
    EditEmployeeIdLbl.frame=CGRectMake(E-90, 90,Employee, 50);
   
    EditEmployeeIdField.frame=CGRectMake(Employee-5, 95,Employee, 40);
   
    EditPasswordlbl.frame=CGRectMake(E-90, 150,Employee, 50);
    
   
    EditPasswordField.frame=CGRectMake(Employee-5, 155,Employee, 40);
   
    EditDisplaynamelbl.frame=CGRectMake(E-90, 210,Employee, 50);
    
  
    EditDisplaynameField.frame=CGRectMake(Employee-5, 215,Employee, 40);
  
    EditCardSwipeIdlbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 30,Employee, 50);
    
   
    EditCardSwipeIdField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 35,Employee, 40);
  
    EditCustomerLbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 90,Employee, 50);
    
    EditCustomerField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 95,Employee, 40);
   
    EditHoulrywagelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 150,Employee, 50);
   
    EditHoulrywageField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 155,Employee, 40);
  
    EditDisablelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 210,Employee+80, 50);
    
    EditdisableBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditDisablelbl.frame.size.width, 220,30, 30);
   
    Editadministrativelbl.frame=CGRectMake(E-90, 270,Employee+100, 50);
    
    EditadministrativeBtn.frame=CGRectMake(E-80+Editadministrativelbl.frame.size.width, 280,30, 30);
   
    EditTakeccTipslbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 250,Employee+80, 100);
    
    EditTakeccTipsBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditTakeccTipslbl.frame.size.width+20, 280,30, 30);
   
    
    
    CGFloat ewidth=(EditemployeeView.frame.size.width)/5;
    CGFloat Exvalue=ewidth/4;
    for (int k=0; k<4; k++)
    {
      
        UIButton *mybtn=(UIButton *)[EditemployeeView viewWithTag:k+100];
        mybtn.frame=CGRectMake(Exvalue,340,ewidth+5, 40);
        [EditemployeeView addSubview:mybtn];
        
        Exvalue=Exvalue+ewidth+15;
        
    }
   
    EditSaveEmployeeBtn.frame=CGRectMake(Employee+100, 450, 80, 30);
    EditCancelEmployeeBtn.frame=CGRectMake(Employee+220, 450, 80, 30);
    
 //Duplicate Employee view
         DuplicateEmployeeIdField.frame=CGRectMake(Employee-5, 95,Employee, 40);
   
        
//Store Data View
        
        
        StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
        
       // StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
   
        StoresView.frame=CGRectMake(100, 50, StoresPopupView.frame.size.width-200, StoresPopupView.frame.size.height-150);
   
       // StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
    
  
    CGFloat widthfield4=(StoresView.frame.size.width)/4;
   
    StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
  
    Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
    StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
    
    StoresListTable .frame=CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100);
    
    StoresDataTable.frame = CGRectMake(50, 200,StoresView.frame.size.width-100, 300) ;
    
    SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
 
    CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
    
    
    }
    else
    {
        CGFloat width,height;
        height=1004;
        width=768;
        // //NSLog(@" %f,%f",width,height);
        
        
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        
        //sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
        // sidemenu.hidden=YES;
        [categorybutton setFrame:CGRectMake(0.0,p,170,40)];
        mainview.frame=CGRectMake(20,60,width-40,height-200);
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        //downtoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
//employee view
        
        EmployeesBackView.frame=CGRectMake(10, 0, mainview.frame.size.width-20, (mainview.frame.size.height));
        
        CGFloat addbuttonwidth=(EmployeesBackView.frame.size.width-10)/2;
        AddEmployeeBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
        
        EditEmployeeBtn.frame=CGRectMake(AddEmployeeBtn.frame.size.width, 10, addbuttonwidth, 40);
        
        
        AddEmployeesView.frame=CGRectMake(10, AddEmployeeBtn.frame.size.height+10, EmployeesBackView.frame.size.width-20, EmployeesBackView.frame.size.height-20-AddEmployeeBtn.frame.size.height);
        AddEmployeesView.contentSize=CGSizeMake(EmployeesBackView.frame.size.width-20,  EmployeesBackView.frame.size.height+100);
        
        CGFloat customerW=(AddEmployeesView.frame.size.width)/4;
        CGFloat r=(customerW/2)+20;
        
        
        Departmentlbl.frame=CGRectMake(r-90, 30,customerW, 50);
    
        DepartmentBtn.frame=CGRectMake(customerW-5, 35,customerW, 40);
        
        
        DepartmentListTable.frame =CGRectMake(customerW-5, 75,customerW, 100);
        
        EmployeeIdLbl.frame=CGRectMake(r-90, 90,customerW, 50);
        
        
        EmployeeIdField.frame=CGRectMake(customerW-5, 95,customerW, 40);
        
        Passwordlbl.frame=CGRectMake(r-90, 150,customerW, 50);
        
        
        PasswordField.frame=CGRectMake(customerW-5, 155,customerW, 40);
        
        Displaynamelbl.frame=CGRectMake(r-90, 210,customerW, 50);
        
        
        DisplaynameField.frame=CGRectMake(customerW-5, 215,customerW, 40);
        
        CardSwipeIdlbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 30,customerW, 50);
        
        
        CardSwipeIdField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 35,customerW, 40);
        
        CustomerLbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 90,customerW, 50);
        
        CustomerField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 95,customerW, 40);
        
        Houlrywagelbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 150,customerW, 50);
        
        HoulrywageField.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+CardSwipeIdlbl.frame.size.width, 155,customerW, 40);
        
        Disablelbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 210,customerW+80, 50);
        
        
        disableBtn.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+Disablelbl.frame.size.width, 220,30, 30);
        
        administrativelbl.frame=CGRectMake(r-90, 270,customerW+100, 50);
        
        administrativeBtn.frame=CGRectMake(r-80+administrativelbl.frame.size.width, 280,30, 30);
        
        TakeccTipslbl.frame=CGRectMake(customerW+5+DisplaynameField.frame.size.width, 250,customerW+80, 100);
        
        TakeccTipsBtn.frame=CGRectMake(customerW-15+DisplaynameField.frame.size.width+TakeccTipslbl.frame.size.width+20, 280,30, 30);
        
        CGFloat wdth=(AddEmployeesView.frame.size.width)/5;
        CGFloat xvalue=wdth/4;
        for (int k=0; k<4; k++)
        {
            UIButton *mybtn=(UIButton *)[AddEmployeesView viewWithTag:k+100];
            mybtn.frame=CGRectMake(xvalue,340,wdth+5, 40);
            [AddEmployeesView addSubview:mybtn];
            
            xvalue=xvalue+wdth+15;
            
        }
        
        SaveEmployeeBtn.frame=CGRectMake(customerW+100, 420, 80, 30);
        CancelEmployeeBtn.frame=CGRectMake(customerW+220, 420, 80, 30);
        
        [[employeepaginationObject   paginationsegment] setFrame:CGRectMake(10, AddEmployeeBtn.frame.size.height+10,EmployeesBackView.frame.size.width-20, 40)];
        
        
        EditEmployeeTable.frame=CGRectMake(10, AddEmployeeBtn.frame.size.height+50, EmployeesBackView.frame.size.width-20, EmployeesBackView.frame.size.height-20-AddEmployeeBtn.frame.size.height-40);
       
//Personal Info View
        
        PersonalInfoPopupView.frame=CGRectMake(0, 0, 768, 1024);
        
        PersonalInfoView.frame=CGRectMake(75, 100, PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height-200);
        PersonalInfoView.contentSize=CGSizeMake(PersonalInfoPopupView.frame.size.width-150, PersonalInfoPopupView.frame.size.height+200);
        
        
        CGFloat fieldwidth=(PersonalInfoView.frame.size.width)/2;
        
        CGFloat o=(fieldwidth/2);
        
        PersonalInfotextlbl.frame=CGRectMake(fieldwidth-110, 10,fieldwidth+100, 40);
        
        int d=70;
        
        for (int i=0; i<10; i++)
        {
            
            
            
            UILabel *mylabel=(UILabel *)[PersonalInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            [PersonalInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[PersonalInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(mylabel.frame.size.width-20, d,fieldwidth-80, 40);
            [PersonalInfoView addSubview:mytextfield];
            
            d=d+60;
            
        }
        SavePersonalInfoBtn.frame=CGRectMake(fieldwidth-100, 720, 80, 30);
        CancelPersonalInfoBtn.frame=CGRectMake(fieldwidth+20, 720, 80, 30);
     
//Payroll View
        
        PayrollPopUpView.frame=CGRectMake(0, 0, 768, 1024);
        
        PayrollView.frame=CGRectMake(25, 100, PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height-300);
        PayrollView.contentSize=CGSizeMake(PayrollPopUpView.frame.size.width-50, PayrollPopUpView.frame.size.height+200);
        
        CGFloat payrollwidth=(PayrollView.frame.size.width)/2;
        CGFloat pay=(payrollwidth/2);
        
        
        PayrollTextLbl.frame=CGRectMake(payrollwidth-80, 10,payrollwidth+100, 40);
        Excludelbl.frame=CGRectMake(pay-160, 60,payrollwidth+80, 40);
        
        ExcludeBtn.frame=CGRectMake(Excludelbl.frame.size.width-150, 65,30, 30);
        
        int k=100;
        
        for (int i=0; i<5; i++)
        {
            UILabel *mylabel=(UILabel *)[PayrollView viewWithTag:i+100];
            mylabel.frame=CGRectMake(pay-175, k,payrollwidth+80, 40);
            [PayrollView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[PayrollView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(mylabel.frame.size.width-10, k,payrollwidth-80, 40);
            [PayrollView addSubview:mytextfield];
            
            k=k+60;
            
        }
        
        Exemptlbl.frame=CGRectMake(pay-175, 400,payrollwidth+80, 40);
        ExemptBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 400,payrollwidth-80, 40);
        ExemptsTable.frame=CGRectMake(Exemptlbl.frame.size.width-5, 440,payrollwidth-80, 100);
        FillingStatuslbl.frame=CGRectMake(pay-175, 460,payrollwidth+80, 40);
        FillingBtn.frame=CGRectMake(Exemptlbl.frame.size.width-10, 460,payrollwidth-80, 40);
        FillingsTable.frame =CGRectMake(Exemptlbl.frame.size.width-5, 500,payrollwidth-80, 100);
        
        SavePayrollBtn.frame=CGRectMake(payrollwidth-100, 620, 80, 30);
        CancelPayrollBtn.frame=CGRectMake(payrollwidth+20, 620, 80, 30);
        
//Permissions View
        
        PermissionsPopupView.frame=CGRectMake(0, 0, 768, 1024);
        
        PermissionsView.frame=CGRectMake(25, 100, PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height-300);
        PermissionsView.contentSize=CGSizeMake(PermissionsPopupView.frame.size.width-50, PermissionsPopupView.frame.size.height+200);
        
        
        CGFloat permissionwidth=(PermissionsView.frame.size.width)/4;
        CGFloat perm=(permissionwidth/2);
        
        PermissonsTextlbl.frame=CGRectMake(permissionwidth+100, 10,permissionwidth+100, 40);
        
        int s=100;
        
        for (int i=0; i<7; i++)
        {
            
            UILabel *mylabel=(UILabel *)[PermissionsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(perm-60, s,permissionwidth+80, 40);
            [PermissionsView addSubview:mylabel];
            
            UISwitch *myswitch=(UISwitch *)[PermissionsView viewWithTag:i+100];
            myswitch.frame=CGRectMake(mylabel.frame.size.width+10, s+5,permissionwidth, 40);
            [PermissionsView addSubview:myswitch];
            
            s=s+60;
            
        }
        int m=100;
        
        for (int i=0; i<7; i++)
        {
            
            UILabel *mylabel=(UILabel *)[PermissionsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(perm+PermissionLbl.frame.size.width, m,permissionwidth+80, 40);
            [PermissionsView addSubview:mylabel];
            
            UISwitch *myswitch=(UISwitch *)[PermissionsView viewWithTag:i+100];
            myswitch.frame=CGRectMake(perm+PermissionLbl.frame.size.width-30+mylabel.frame.size.width+40, m+5,permissionwidth, 40);
            [PermissionsView addSubview:myswitch];
            
            m=m+60;
            
        }
        
        SavePermissionBtn.frame=CGRectMake(permissionwidth+100, 580, 80, 30);
        CancelPermissionsBtn.frame=CGRectMake(permissionwidth+220, 580, 80, 30);
       
        
//Edit Employee View
        
        EditEmployeePopUp.frame=CGRectMake(0, 0, 768, 1024);
        
        //EditemployeeView.frame=CGRectMake(20, 100, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-200);
        
        
         EditemployeeView.frame=CGRectMake(20, 200, EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height-500);
        
        EditemployeeView.contentSize=CGSizeMake(EditEmployeePopUp.frame.size.width-40, EditEmployeePopUp.frame.size.height+100);
        
        
        CGFloat Employee=(EditemployeeView.frame.size.width)/4;
        CGFloat E=(Employee/2)+20;
        
        
        EditDepartmentlbl.frame=CGRectMake(E-90, 30,Employee, 50);
        
        EditDepartmentBtn.frame=CGRectMake(Employee-5, 35,Employee, 40);
        
        EditDepartmentListTable.frame = CGRectMake(Employee-5, 75,Employee, 100);
        
        EditEmployeeIdLbl.frame=CGRectMake(E-90, 90,Employee, 50);
        
        EditEmployeeIdField.frame=CGRectMake(Employee-5, 95,Employee, 40);
        
        EditPasswordlbl.frame=CGRectMake(E-90, 150,Employee, 50);
        
        
        EditPasswordField.frame=CGRectMake(Employee-5, 155,Employee, 40);
        
        EditDisplaynamelbl.frame=CGRectMake(E-90, 210,Employee, 50);
        
        
        EditDisplaynameField.frame=CGRectMake(Employee-5, 215,Employee, 40);
        
        EditCardSwipeIdlbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 30,Employee, 50);
        
        
        EditCardSwipeIdField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 35,Employee, 40);
        
        EditCustomerLbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 90,Employee, 50);
        
        EditCustomerField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 95,Employee, 40);
        
        EditHoulrywagelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 150,Employee, 50);
        
        EditHoulrywageField.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditCardSwipeIdlbl.frame.size.width, 155,Employee, 40);
        
        EditDisablelbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 210,Employee+80, 50);
        
        EditdisableBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditDisablelbl.frame.size.width, 220,30, 30);
        
        Editadministrativelbl.frame=CGRectMake(E-90, 270,Employee+100, 50);
        
        EditadministrativeBtn.frame=CGRectMake(E-80+Editadministrativelbl.frame.size.width, 280,30, 30);
        
        EditTakeccTipslbl.frame=CGRectMake(Employee+5+EditDisplaynameField.frame.size.width, 250,Employee+80, 100);
        
        EditTakeccTipsBtn.frame=CGRectMake(Employee-15+EditDisplaynameField.frame.size.width+EditTakeccTipslbl.frame.size.width+20, 280,30, 30);
        
        
        
        CGFloat ewidth=(EditemployeeView.frame.size.width)/5;
        CGFloat Exvalue=ewidth/4;
        for (int k=0; k<4; k++)
        {
            
            UIButton *mybtn=(UIButton *)[EditemployeeView viewWithTag:k+100];
            mybtn.frame=CGRectMake(Exvalue,340,ewidth+5, 40);
            [EditemployeeView addSubview:mybtn];
            
            Exvalue=Exvalue+ewidth+15;
            
        }
        
        EditSaveEmployeeBtn.frame=CGRectMake(Employee+100, 450, 80, 30);
        EditCancelEmployeeBtn.frame=CGRectMake(Employee+220, 450, 80, 30);
        
        
//Duplicate Employee view
        DuplicateEmployeeIdField.frame=CGRectMake(Employee-5, 95,Employee, 40);
        
        
//Store Data View
        
        
        //StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
        
       StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
        
        //StoresView.frame=CGRectMake(100, 50, StoresPopupView.frame.size.width-200, StoresPopupView.frame.size.height-150);
        
        StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
        
        
        CGFloat widthfield4=(StoresView.frame.size.width)/4;
        
        StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
        
        Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
        StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
        
        StoresListTable .frame=CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100);
        
        StoresDataTable.frame = CGRectMake(50, 200,StoresView.frame.size.width-100, 300) ;
        
        SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
        
        CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
        
    }
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if(textField == EditEmployeeIdField)
    {
        [textField resignFirstResponder];
        // Show you custom picker here....
        return NO;
    }
    return YES;
}
-(void)menuclicked
{
    if (menuslected == false)
    {
        
        // //NSLog(@"called");
        // //NSLog(@"%d",menuslected);
        menuslected=YES;
        logoBtn.hidden=YES;
        
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(0,0);
        //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
        //sidemenu.hidden=NO;
       // [UIView commitAnimations];
        [backgroundcolorview addSubview:sidemenu];
        
       // [UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:0.9f];
        menubutton.transform = CGAffineTransformMakeTranslation(180,0);
        
        menubutton.transform = CGAffineTransformRotate( menubutton.transform, - M_PI);
        //[UIView commitAnimations];
       // [UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        
        
    }else
    {
        logoBtn.hidden=NO;
        menuslected=NO;
        
      //  [UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
        
        //[UIView commitAnimations];
       
       // [UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        menubutton.transform = CGAffineTransformMakeTranslation(0,0);
        
        
        //[UIView commitAnimations];
        //[UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        
    }
    
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
    logoBtn.hidden=NO;
    //[UIView beginAnimations:nil context:NULL];
    //[UIView setAnimationDuration:0.8f];
    mainview.transform = CGAffineTransformMakeTranslation(0,0);
    
    
    //[UIView commitAnimations];
    //[UIView beginAnimations:nil context:NULL];
    //[UIView setAnimationDuration:0.8f];
    sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
    //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
    
   // [UIView commitAnimations];
    //[UIView commitAnimations];
    ////[UIView beginAnimations:nil context:NULL];
   // [UIView setAnimationDuration:0.0f];
    menubutton.transform = CGAffineTransformMakeTranslation(0,0);
    
    
    //[UIView commitAnimations];
    //[UIView beginAnimations:nil context:NULL];
    //[UIView setAnimationDuration:0.0f];
    menuslected=NO;
}

-(void)helpiconclicked
{
    
}
-(void)logoutButtonClicked
{
       [serverSyncClassObject LogoutMethod];
    
    NSString *updateSQL =@"UPDATE miscellaneous SET userType=?,sessionId=?,userID=?";
    NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:@"",@"",@"", nil];
    [[DataBaseManager dataBaseManager] executeRecordsWithQuery:updateSQL withArguments:misUpdatearray];
   [self.navigationController popToRootViewControllerAnimated:YES];
    [generalDataObject  releasevariable];
    [self releaseViews];
}
-(void)categotybuttonclicked:(UIButton *)sender
{
    NSArray *viewS = [self.navigationController viewControllers];
    //NSLog(@"nav views %@",viewS);
    NSInteger selectedrow=sender.tag;
    if(selectedrow == 0){
        Home *homeview=[[Home alloc]initWithNibName:@"Home" bundle:Nil];
        NSString *returnvalue;
        NSInteger selectedview;
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Home class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        ////NSLog(@"%d",selectedview);
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else{
            
            [self.navigationController pushViewController:homeview animated:NO];
            [self releaseViews];
        }
    }else if(selectedrow == 5){
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                [sender setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
                NSString *returnvalue;
                NSInteger selectedview;
                Settings  *settingsview=[[Settings alloc]initWithNibName:@"Settings" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Settings class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:settingsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            [sender setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
            NSString *returnvalue;
            NSInteger selectedview;
            Settings  *settingsview=[[Settings alloc]initWithNibName:@"Settings" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Settings class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                [self.navigationController pushViewController:settingsview animated:NO];
                [self releaseViews];
            }
            
            
        }
        
        
    }else if(selectedrow == 8){
        NSString *returnvalue;
        NSInteger selectedview;
        Stores *storesview=[[Stores alloc]initWithNibName:@"Stores" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Stores class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:storesview animated:NO];
            [self releaseViews];
        }
        
    }else if(selectedrow == 2){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  inventory_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Inventory *inventoryview=[[Inventory alloc]initWithNibName:@"Inventory" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Inventory class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:inventoryview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }
        else
        {
            
            NSString *returnvalue;
            NSInteger selectedview;
            Inventory *inventoryview=[[Inventory alloc]initWithNibName:@"Inventory" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Inventory class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:inventoryview animated:NO];
                [self releaseViews];
            }
        }
    }else if(selectedrow == 3){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  customer_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Customers *customersview=[[Customers alloc]initWithNibName:@"Customers" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Customers class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:customersview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Customers *customersview=[[Customers alloc]initWithNibName:@"Customers" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Customers class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:customersview animated:NO];
                [self releaseViews];
            }
        }
        
    }else if(selectedrow == 1){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Profile *profileview=[[Profile alloc]initWithNibName:@"Profile" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Profile class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:profileview animated:NO];
                [self releaseViews];
            }
            
        }else{
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
            authalert=nil;
        }
    }else if(selectedrow == 6){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:reportsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:reportsview animated:NO];
                [self releaseViews];
            }
            
        }
        
    }else if(selectedrow == 7){
        NSString *returnvalue;
        NSInteger selectedview;
        Contacts *contactsview=[[Contacts alloc]initWithNibName:@"Contacts" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Contacts class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:contactsview animated:NO];
            [self releaseViews];
        }

    }
    
 }

-(void)releaseViews
{
    
    NSArray *mainArray = self.view.subviews;
    for (int i = 0; i<[mainArray count]; i++) {
        UIView *vi =[mainArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *sideArray = sidemenu.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = navBar.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [sidemenu removeFromSuperview],[mainview removeFromSuperview],[backgroundcolorview removeFromSuperview];
    sidemenu=nil,mainview=nil,backgroundcolorview=nil;
    categorybutton=nil;
    downtoolBar=nil,maintoolBar=nil;
    logobackview=nil,logoimageview=nil;
    
    helpiconButton=nil,logouticonButton=nil,menubutton=nil;
    backButton3=nil,backButton2=nil,backButton=nil;
    navBar=nil;
    
    NSArray *AddEmployeesViewArray = AddEmployeesView.subviews;
    for (int i = 0; i<[AddEmployeesViewArray count]; i++) {
        UIView *vi =[AddEmployeesViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *EmployeesBackViewArray = EmployeesBackView.subviews;
    for (int i = 0; i<[EmployeesBackViewArray count]; i++) {
        UIView *vi =[EmployeesBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddEmployeesView removeFromSuperview],[EmployeesBackView removeFromSuperview];
    EmployeesBackView=nil;
    AddEmployeesView=nil;
    AddEmployeeBtn=nil,EditEmployeeBtn=nil;
    
    DepartmentBtn=nil;
    EmployeeIdLbl=nil,Passwordlbl=nil,Displaynamelbl=nil,CardSwipeIdlbl=nil,CustomerLbl=nil,Houlrywagelbl=nil,Departmentlbl=nil;
    EmployeeIdField=nil,PasswordField=nil,DisplaynameField=nil,CardSwipeIdField=nil,CustomerField=nil,HoulrywageField=nil;
    EmployeeInfoBtn=nil;
    DepartmentListTable=nil;
    [DepartmentsArray removeAllObjects];
    DepartmentsArray=nil;
    Disablelbl=nil,administrativelbl=nil,TakeccTipslbl=nil;
    disableBtn=nil,administrativeBtn=nil,TakeccTipsBtn=nil;
    EditBtn=nil,DuplicateBtn=nil,DeleteBtn=nil;
    
    SaveEmployeeBtn=nil,CancelEmployeeBtn=nil;
    EditEmployeeTable=nil;
    
    Disable=nil,administrative=nil,Cctips=nil;
    [EmDepartmentsArray removeAllObjects],[EmployeeIdsArray removeAllObjects],[passwordsArray removeAllObjects],[DisplayNamesArray removeAllObjects],[cardswipeidsArray removeAllObjects],[EmCustomersArray removeAllObjects],[houlrywagesArray removeAllObjects],[disablesArray removeAllObjects],[CctipsArray removeAllObjects],[administativesArray  removeAllObjects];
    EmDepartmentsArray=nil,EmployeeIdsArray=nil,passwordsArray=nil,DisplayNamesArray=nil,cardswipeidsArray=nil,EmCustomersArray=nil,houlrywagesArray=nil,disablesArray=nil,CctipsArray=nil,administativesArray =nil;
    CheckEmployeeID=nil;
    
    //Personal Info View
    NSArray *PersonalInfoViewArray = PersonalInfoView.subviews;
    for (int i = 0; i<[PersonalInfoViewArray count]; i++) {
        UIView *vi =[PersonalInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PersonalInfoPopupViewArray = PersonalInfoPopupView.subviews;
    for (int i = 0; i<[PersonalInfoPopupViewArray count]; i++) {
        UIView *vi =[PersonalInfoPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PersonalInfoView removeFromSuperview],[PersonalInfoPopupView removeFromSuperview];
    PersonalInfoPopupView=nil;
    PersonalInfoView=nil;
    PersonalInfotextlbl=nil;
    PersonalInfoField=nil;
    PersonalInfolbl=nil;
    SavePersonalInfoBtn=nil,CancelPersonalInfoBtn=nil;
    Name=nil,ID=nil,Email=nil,Phonenumber=nil,Birthday=nil,Address=nil,City=nil,Country=nil,state=nil,Zipcode=nil;
    [NamesArray removeAllObjects],[IDsArray removeAllObjects],[EmailsArray removeAllObjects],[PhonenumbersArray removeAllObjects],[BirthdaysArray removeAllObjects],[AddresssArray removeAllObjects],[CitysArray removeAllObjects],[CountrysArray removeAllObjects],[statesArray removeAllObjects],[ZipcodesArray removeAllObjects];
    NamesArray=nil,IDsArray=nil,EmailsArray=nil,PhonenumbersArray=nil,BirthdaysArray=nil,AddresssArray=nil,CitysArray=nil,CountrysArray=nil,statesArray=nil,ZipcodesArray=nil;
    
    //Payroll View
    NSArray *PayrollViewArray = PayrollView.subviews;
    for (int i = 0; i<[PayrollViewArray count]; i++) {
        UIView *vi =[PayrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PayrollPopUpViewArray = PayrollPopUpView.subviews;
    for (int i = 0; i<[PayrollPopUpViewArray count]; i++) {
        UIView *vi =[PayrollPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PayrollView removeFromSuperview],[PayrollPopUpView removeFromSuperview];
    PayrollPopUpView=nil;
    PayrollView=nil;
    ExcludeBtn=nil;
    Excludelbl=nil;
    PayrollLbl=nil,PayrollTextLbl=nil;
    PayrollField=nil;
    Exemptlbl=nil,FillingStatuslbl=nil;
    ExemptBtn=nil,FillingBtn=nil,SavePayrollBtn=nil,CancelPayrollBtn=nil;
    ExemptsTable=nil,FillingsTable=nil;
    Exclude=nil,federal=nil,federalAmount=nil,stateallowances=nil,stateAmount=nil,credits=nil,Exempt=nil,Filling=nil;
    [ExemptsArray removeAllObjects],[FillinsArray removeAllObjects];  [ExcludesArray removeAllObjects],[federalsArray removeAllObjects],[federalAmountsArray removeAllObjects],[stateallowancessArray removeAllObjects],[stateAmountsArray removeAllObjects],[creditssArray removeAllObjects],[DataExemptsArray removeAllObjects],[DataFillingsArray removeAllObjects];
    ExemptsArray=nil,FillinsArray=nil;
    
    ExcludesArray=nil,federalsArray=nil,federalAmountsArray=nil,stateallowancessArray=nil,stateAmountsArray=nil,creditssArray=nil,DataExemptsArray=nil,DataFillingsArray=nil;
    
    //Permissions View
    NSArray *PermissionsViewArray = PermissionsView.subviews;
    for (int i = 0; i<[PermissionsViewArray count]; i++) {
        UIView *vi =[PermissionsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PermissionsPopupViewArray = PermissionsPopupView.subviews;
    for (int i = 0; i<[PermissionsPopupViewArray count]; i++) {
        UIView *vi =[PermissionsPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PermissionsView removeFromSuperview],[PermissionsPopupView removeFromSuperview];
    PermissionsPopupView=nil;
    PermissionsView=nil;
    PermissonsTextlbl=nil,PermissionLbl=nil,Permissionlbl2=nil;
    Myswitch=nil,SecondSwitch=nil;
    SavePermissionBtn=nil,CancelPermissionsBtn=nil;
    inventory=nil,reports=nil,settings=nil,allowexit=nil,deleteitems=nil,endTransactions=nil,forceCreditcard=nil,customers=nil,invoicediscounts=nil,pricechnages=nil,payouts=nil,voidinvoices=nil,hold=nil,endcash=nil;
    [inventorysArray removeAllObjects],[reportssArray removeAllObjects],[settingssArray removeAllObjects],[allowexitsArray removeAllObjects],[deleteitemssArray removeAllObjects],[endTransactionssArray removeAllObjects],[forceCreditcardsArray removeAllObjects],[customerssArray removeAllObjects],[invoicediscountssArray removeAllObjects],[pricechnagessArray removeAllObjects],[payoutssArray removeAllObjects],[voidinvoicessArray removeAllObjects],[holdsArray removeAllObjects],[endcashsArray removeAllObjects];
    inventorysArray=nil,reportssArray=nil,settingssArray=nil,allowexitsArray=nil,deleteitemssArray=nil,endTransactionssArray=nil,forceCreditcardsArray=nil,customerssArray=nil,invoicediscountssArray=nil,pricechnagessArray=nil,payoutssArray=nil,voidinvoicessArray=nil,holdsArray=nil,endcashsArray=nil;
    
    
    DeleteEmployeeAlert=nil;
    
    //Edit Employee View
    NSArray *EditemployeeViewArray = EditemployeeView.subviews;
    for (int i = 0; i<[EditemployeeViewArray count]; i++) {
        UIView *vi =[EditemployeeViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditEmployeePopUpArray = EditEmployeePopUp.subviews;
    for (int i = 0; i<[EditEmployeePopUpArray count]; i++) {
        UIView *vi =[EditEmployeePopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditemployeeView removeFromSuperview],[EditEmployeePopUp removeFromSuperview];
    EditEmployeePopUp=nil;
    EditemployeeView=nil;
    
    EditDepartmentBtn=nil;
    EditEmployeeIdLbl=nil,EditPasswordlbl=nil,EditDisplaynamelbl=nil,EditCardSwipeIdlbl=nil,EditCustomerLbl=nil,EditHoulrywagelbl=nil,EditDepartmentlbl=nil;
    EditEmployeeIdField=nil,EditPasswordField=nil,EditDisplaynameField=nil,EditCardSwipeIdField=nil,EditCustomerField=nil,EditHoulrywageField=nil;
    EditEmployeeInfoBtn=nil;
    EditDepartmentListTable=nil;
    
    EditDisablelbl=nil,Editadministrativelbl=nil,EditTakeccTipslbl=nil;
    EditdisableBtn=nil,EditadministrativeBtn=nil,EditTakeccTipsBtn=nil;
    EditSaveEmployeeBtn=nil,EditCancelEmployeeBtn=nil;
    
    //Duplicate Employee View=nil;
    
    DuplicateEmployeeIdField=nil;
    EConnection=nil,PermissionsConnection=nil,PayrollConnections=nil,PersonalConnection=nil,StoreConnection=nil;
    EResponseData=nil,PermissionsResponseData=nil,PayrollResponseData=nil,PersonalResponseData=nil,StoreResponseData=nil;
    
    //Stores View
    NSArray *StoresViewArray = StoresView.subviews;
    for (int i = 0; i<[StoresViewArray count]; i++) {
        UIView *vi =[StoresViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *StoresPopupViewArray = StoresPopupView.subviews;
    for (int i = 0; i<[StoresPopupViewArray count]; i++) {
        UIView *vi =[StoresPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [StoresView removeFromSuperview],[StoresPopupView removeFromSuperview];
    StoresPopupView=nil,StoresView=nil;
    Storeslbl=nil,StoresTextlbl=nil;
    StoresListTable=nil,StoresDataTable=nil;
    SavestoresBtn=nil,CancelStoresBtn=nil,StoresBtn=nil,DeleteStoreBtn=nil;
    
    [StoreDataArray removeAllObjects],[SelectedStoredataArray removeAllObjects],[StoreIdsArray removeAllObjects],[SeleCtedStoreIdsArray removeAllObjects];
   [StoredataFromdatabaseArray removeAllObjects],[DBstorenamesArray removeAllObjects],[BdStoreidsArray removeAllObjects];
    StoreDataArray=nil,SelectedStoredataArray=nil,StoreIdsArray=nil,SeleCtedStoreIdsArray=nil;
    StoredataFromdatabaseArray=nil,DBstorenamesArray=nil,BdStoreidsArray=nil;
    
    
    sationLbl=nil,Timelbl=nil,EmpIdlbl=nil;
    logoBtn=nil;
    
    
    EmpPassword=nil;
    
    leavePasswordlbl=nil;
    dataDict=nil;
    
    employeeCell=nil;
    
    [self.view removeFromSuperview];
    self.view=nil;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{
    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight||toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) {
        isLandScope=YES;
        
    }else
    {
        isLandScope=NO;
    }
    [self updateUI];
}



- (NSUInteger)supportedInterfaceOrientations // iOS 6 autorotation fix
{
    return UIInterfaceOrientationMaskAll;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    NSArray *viewS = [self.navigationController viewControllers];
    [self.navigationController popToViewController:[viewS objectAtIndex:1] animated:YES];
    [self releaseViews];
    // Dispose of any resources that can be recreated.
}

@end
